xtandard holds the utilities we kept rewriting. When a well-maintained, permissively licensed library already does the job well, we recommend it instead of rebuilding it. None of these are re-exported: install the ones you need directly.
Each card says what the library provides, why we pick it over the alternatives, and, where it applies, which xtandard entry point it pairs with, with an example. Licenses and latest releases come from the npm registry and GitHub, checked by bun run recs:check.
Modern utility functions for arrays, objects, functions, strings and promises.
Written in TypeScript, tree-shakable and actively maintained by Toss. Its `es-toolkit/compat` layer mirrors lodash call for call, so a migration can happen one import at a time.
Deep clone with modes for JSON-only, lite and full (Map, Set, typed arrays, class instances) data.
240 to 501 bytes gzipped depending on the mode, and fast. Pick the smallest mode that covers your data. For plain data, the built-in `structuredClone` is also an option.
Immutable updates written as mutations on a draft, like Immer.
Same draft-based model as Immer, but faster in the project's published benchmarks: about 3.6x with the same settings across 97 workloads, and more on large arrays.
Pattern matching with exhaustiveness checking: `match(value).with(pattern, handler).exhaustive()`.
The compiler checks that every case of a union or nested shape is handled, and each branch gets the narrowed type. Reads better than nested `switch`/`if` chains.
Instead of: switch statements over discriminated unions
A lightweight `Result` type with generator-based composition (`yield*`) and tagged error classes.
Multi-step workflows read as straight-line code. `TaggedError` gives discriminated error unions, and an unexpected throw becomes a `Panic` instead of widening the error type to `unknown`. Zero runtime dependencies.
Pairs with@xtandard/lib: Use `tryCatch` for one-off calls; use better-result when a function's failure modes are part of its public type.
`Result` and `ResultAsync` types for typed, chainable error handling.
A mature, widely used Result library. `ResultAsync` keeps promise chains typed, and an ESLint plugin flags results you forgot to handle.
Pairs with@xtandard/lib: `tryCatch` turns one throwing call into a `[data, error]` tuple. Reach for neverthrow (or better-result) when errors must flow through many chained steps with their types intact.
Async, concurrency & resilience
Bounded concurrency, queues, retries and circuit breakers.
Resilience policies: retry with backoff, circuit breaker, timeout, bulkhead and fallback, composable with `wrap`.
Modeled on .NET's Polly. Typed, zero dependencies, and the policies compose, so one call can get retry, a circuit breaker and a timeout together.
Pairs with@xtandard/lib: Run the call through a policy and wrap it in `tryCatch` to get a `[data, error]` tuple once retries are exhausted or the breaker is open.
Map over an iterable or async iterable with a concurrency limit.
The standard answer when `Promise.all` would start too much at once. It can stop or continue on errors, and has settled, keyed and streaming (`pMapIterable`) variants.
Pairs with@xtandard/lib/pagination: A paginator's `items()` is an async iterable, so p-map can process every row with bounded concurrency while pages are fetched lazily.
A promise queue with concurrency control, priorities and interval-based rate limiting.
Zero dependencies and battle-tested. It covers both 'at most N at a time' and 'at most N per interval' (API rate limits).
Pairs with@xtandard/lib: Push each finished task into an `AsyncChannel` and consume the results as an async iterable, or hand the channel to `toastStream` / `StreamRenderer`.
Example
import PQueue from "p-queue";
import { AsyncChannel } from "@xtandard/lib";
const queue = new PQueue({ concurrency: 4 });
const reports = AsyncChannel.create<Report>();
for (const id of ids) void queue.add(async () => reports.push(await buildReport(id)));
void queue.onIdle().then(() => reports.close());
for await (const report of reports) render(report);
Caching & storage
Key-value storage, caches with stale-while-revalidate, file and blob storage.
Wraps any cache (lru-cache, Redis, SQLite, Cloudflare KV through adapters) with TTL, stale-while-revalidate, value validation and batching.
Adds what a plain TTL cache lacks: serve stale values while refreshing in the background, validate or migrate cached values (for example with a schema), force a fresh value with fallback to the cache, and share one `getFreshValue` call between concurrent misses for the same key.
Instead of: cachified (the package's old name, deprecated on npm)
Pairs with@xtandard/lib/unstorage: Keep `createCache` for simple TTL caching on an unstorage driver. Switch to cachified when you need stale-while-revalidate, validation of cached values, or concurrent misses for the same key to share one fetch (within a process). `createCache` does none of these, on purpose.
Example
import { LRUCache } from "lru-cache";
import { cachified, type CacheEntry } from "@epic-web/cachified";
const cache = new LRUCache<string, CacheEntry>({ max: 1000 });
const user = await cachified({
key: `user-${id}`,
cache,
ttl: 60_000,
staleWhileRevalidate: 300_000,
getFreshValue: () => db.users.findById(id),
});
A multi-tier cache for Node.js: an in-memory L1 in front of a distributed L2 (Redis, Upstash, DynamoDB, SQL databases, filesystem…), kept in sync across instances by a bus.
A real caching layer rather than a storage bridge: cache stampede protection, grace periods that serve stale data when the store is down or slow, timeouts, tags, namespaces, events and OpenTelemetry instrumentation.
Pairs with@xtandard/lib/unstorage: Prefer bentocache over `createCache` when several app instances share a cache and you want a local in-memory tier kept consistent through a bus, stampede protection, grace periods or tag-based invalidation.
Example
import { BentoCache, bentostore } from "bentocache";
import { memoryDriver } from "bentocache/drivers/memory";
import { redisDriver } from "bentocache/drivers/redis";
const bento = new BentoCache({
default: "app",
stores: {
app: bentostore()
.useL1Layer(memoryDriver({ maxSize: "10mb" }))
.useL2Layer(redisDriver({ connection: { host: "127.0.0.1", port: 6379 } })),
},
});
// Concurrent misses for the same key run the factory once.
const user = await bento.getOrSet({
key: `user:${id}`,
ttl: "1m",
factory: () => db.users.findById(id),
});
Built for Node.js servers, not browsers or edge runtimes.
One API over object and blob storage: S3 and S3-compatible services (R2, MinIO, B2…), Google Cloud Storage, Azure Blob Storage, Vercel Blob and more.
Web-standard I/O, and switching providers means changing one adapter import. Each provider's SDK is an optional peer dependency, and the native client is available when you need it.
Requires Node.js 22+ (also runs on Bun, Deno and Cloudflare Workers).
npm's `latest` tag currently points at a v2 beta (2.0.0-beta.0). `@xtandard/lib/unstorage` targets v1 until 2.0 is stable, so install `unstorage@^1` with it.
Numbers, money & units
Exact decimals and rationals, money, and byte sizes.
date-fns-style functions for the Temporal API: time zone conversion, DST-safe date math, formatting, parsing and business days.
If you know date-fns, these are the same names and argument order, on Temporal types.
Pairs with@xtandard/lib/temporal: Use tiempo for date math and formatting on Temporal values, and `@xtandard/lib/temporal` for intervals of them (`ZonedDateTimeInterval`, `PlainDateInterval`…) and `Date` ↔ Temporal conversion.
Cron scheduling and cron-expression evaluation in Node.js, Deno, Bun and browsers, with time zones.
Zero dependencies. Supports seconds and year fields and the `L`, `W` and `#` modifiers, and can compute the next run times without scheduling anything.
RFC 5545 recurrence rules (RRULE) on the Temporal API, with time zones and RFC 7529 non-Gregorian calendars.
Occurrences are `Temporal.ZonedDateTime` values, so they stay correct across DST changes. Works with native Temporal or either polyfill, and can return your app's own Temporal objects.
Instead of: rrule (built on Date)
Pairs with@xtandard/lib/temporal: Expand a rule into occurrences, then turn each into a `ZonedDateTimeInterval` to check availability or overlaps. Pass your `Temporal` so the occurrences are instances of it.
Audited, dependency-free implementations of SHA-2, SHA-3, BLAKE, RIPEMD-160, HMAC, HKDF, PBKDF2, scrypt and Argon2.
Audited by an independent security firm, pure TypeScript, and runs on every platform. Use it when WebCrypto lacks the algorithm or you need synchronous hashing.
Tiny, secure, URL-friendly unique string IDs, with custom alphabets and lengths.
117 bytes (minified and brotlied) with no dependencies, uses a cryptographically secure random source, and is faster than `crypto.randomUUID()` according to its README.
Instead of: uuid v4 strings when you don't need the UUID format
TypeIDs: type-prefixed, sortable IDs (`user_01h…`) built on UUIDv7. The official TypeScript implementation of the TypeID spec.
TypeID is a cross-language spec, the prefix is part of the type (`TypeID<"user">`), and the suffix converts to and from a UUID, so IDs fit `uuid` columns.
Pairs with@xtandard/lib/ulid: `@xtandard/lib/ulid` makes prefixed ULIDs as plain strings, with no spec behind them. Prefer typeid-js when IDs cross languages, must be stored as UUIDs, or you want the prefix checked by the compiler.
Example
import { TypeID, typeid } from "typeid-js";
const id = typeid("user"); // TypeID<"user">
id.toString(); // "user_01m7y054epfzyv34cn1nzk5t99"
TypeID.fromString(id.toString(), "user").toUUID(); // "01a1fc02-91d6-7ffd-…"
Parsing & formats
Versions, IP addresses, JSON supersets, URL-friendly encodings and HTML.
A small web framework on Web Standards for Cloudflare Workers, Deno, Bun, Node.js, AWS Lambda and more.
Zero dependencies (the `hono/tiny` preset is under 12 kB), the same code on every runtime, and many built-in middlewares.
Pairs with@xtandard/lib/filters: List endpoints: validate the incoming filter request with the ready-made schemas, render it with a database adapter, and serve pages with `@xtandard/lib/pagination`.
Stripe-style `Idempotency-Key` middleware for Hono, following the IETF idempotency-key header draft.
Request fingerprinting rejects a reused key with a different payload, concurrent duplicates are locked out, and replays return the stored response. Errors are RFC 9457 problem details. Stores: memory, Redis, Cloudflare KV and D1, Durable Objects.
Young and pre-1.0 (0.9.x), with a small community.
Cursor-based pagination for Drizzle ORM: any number of cursor columns, custom serialization, SQL expressions, query builder and relational queries.
A focused, single-purpose library for keyset pagination on Drizzle.
Pairs with@xtandard/lib/pagination/drizzle: Both do keyset pagination on Drizzle. `@xtandard/lib/pagination` adds offset and page modes, the same API across ORMs, and frontend helpers.
Postgres compiled to WASM: in-memory, or persisted to the filesystem (Node.js, Bun, Deno) or IndexedDB (browsers).
Real Postgres without a server: 3 MB gzipped, with extensions such as pgvector and PostGIS. Good for tests and local-first apps.
Pairs with@xtandard/lib/filters/drizzle: Run your filter and pagination queries against real Postgres in-process, for example through Drizzle's PGlite driver in tests.
A framework-agnostic authentication (and authorization) framework for TypeScript: email and password, social sign-in, sessions, and plugins for 2FA, multi-tenancy and more.
Users and sessions live in your own database, and its plugin ecosystem covers what often needs a hosted auth service.
Isomorphic authorization: define what a user can do with which resources, and check it in the API and the UI.
The core is about 6 KB minified and gzipped, rules can be serialized and shared with the frontend, and there are integrations for React, Vue, Angular, Mongoose and Prisma.
Type-safe permissions from one typed schema, framework-agnostic, on the client and the server.
Lightweight, and a permission that is misspelled or missing is a TypeScript error. Integrations exist for UI frameworks, SSR hydration and server middleware.
Patterns for agentic interfaces (chat, messages, reasoning, tool calls, plans, sources, prompt input…) built from shadcn/ui components and copied into your project with the `shadcn` CLI.
There is no package to install: the code is yours to change. The steps an agent takes share one `Trace` component, which works with the AI SDK's reasoning, tool and source parts. It replaces the AI SDK's own AI Elements (elements.ai-sdk.dev), which is deprecated in its favour.
Instead of: ai-elements (elements.ai-sdk.dev)
Copy-in components, not a dependency: `recs:check` tracks the `shadcn` CLI that installs them. Needs a project set up with shadcn/ui and Tailwind CSS.
A provider-agnostic toolkit for LLM apps and agents: text and structured generation, tool calling, streaming, and UI hooks for React, Svelte, Vue and Angular.
One API across OpenAI, Anthropic, Google and the other providers, with first-class streaming.
End-to-end typed notifications for Node.js and Bun: email, SMS, push, Slack, Discord, Telegram and more from one catalog.
One catalog type drives the client, the queue worker and the webhook router, transports can be swapped, and middleware (rate limits, idempotency, tracing) is built in.
Headless table and datagrid logic: sorting, filtering, grouping, pagination, column visibility and more.
You keep full control of the markup and styling, and it scales from simple tables to complex datagrids.
Pairs with@xtandard/lib/filters: For server-side tables, express column filters and sorting as a filter request and sort spec, and serve pages with `@xtandard/lib/pagination`.
Type-safe URL search-param state for React: like `useState`, but stored in the query string.
Adapters for Next.js (app and pages routers), plain React, Remix and React Router, with parsers and serializers.
Pairs with@xtandard/lib/tanstack: `@xtandard/lib/tanstack` is a nuqs-style API built on TanStack Router's own search params (with server parsers, a testing adapter, and Temporal and Rison codecs). nuqs's TanStack Router adapter is experimental, so use nuqs on the other routers.
Unstyled, accessible React components (dialog, drawer, menu, popover, select, combobox, toast…) in one tree-shakable package.
From the creators of Radix, Floating UI and Material UI. Its Drawer (swipe to dismiss, snap points, nested drawers) is what shadcn/ui's Base UI drawer moved to from vaul, which is unmaintained.
A zero-dependency spreadsheet engine: read and write XLSX, CSV and ODS, with schema validation and streaming.
Pure TypeScript that runs everywhere, edge runtimes included, and much smaller than the usual spreadsheet libraries (the CSV-only import is about 2 KB gzipped).