Entry points
Ten stable generator entry points behind one consistent, type-safe API.
uniku exposes ten ID generation modules. Each module exports a callable generator with attached helpers. The most common public API looks like this:
import { uuidv7 } from 'uniku/uuid/v7'
const id = uuidv7()
// e.g. '019f5732-0342-75f9-9efd-fc3c1f8da7fd'
uuidv7.isValid(id)
// true
const bytes = uuidv7.toBytes(id)
// Uint8Array(16)
uuidv7.fromBytes(bytes)
// the same value as `id`
uuidv7.timestamp(id)
// e.g. 1783874323266
uuidv7.NIL
// '00000000-0000-0000-0000-000000000000'
uuidv7.MAX
// 'ffffffff-ffff-ffff-ffff-ffffffffffff'Binary modules can also write directly into a caller-owned buffer:
const destination = new Uint8Array(24)
const result = uuidv7(undefined, destination, 8)
// Uint8Array(24), with UUID bytes at offsets 8 through 23
result === destination
// trueHow modules differ
| Modules | Public API |
|---|---|
uuid/v7, ulid, ksuid, objectid, xid | Callable, buffer write, toBytes(), fromBytes(), timestamp(), isValid(), NIL, MAX |
uuid/v4 | Callable, buffer write, toBytes(), fromBytes(), isValid(), NIL, MAX |
typeid | Prefix-first callable, buffer write, toBytes(), fromBytes(), toUuid(), fromUuid(), timestamp(), prefix(), suffix(), isValid() |
tsid | bigint primary value, buffer write, toBytes(), fromBytes(), toString(), fromString(), timestamp(), isValid(), NIL, MAX |
cuid/v2, nanoid | Callable, isValid() only |
This table is derived from the generated TypeScript API reference. Open a module's page for complete signatures, options, constants, and examples.
The package root is intentionally not exported, so import a generator or metadata module directly. Two metadata entry points round out the library:
| Import | Purpose |
|---|---|
uniku/errors | Typed, machine-readable input, parse, and buffer errors. |
uniku/generators | The canonical ordered list of supported generator kinds. |
Generator references
Read the reference for the module you use. Each Public API section is generated from the TypeScript signatures and JSDoc in packages/uniku/src, so it stays aligned with the library source.
UUID v4
Random, standards-compatible UUIDs.
UUID v7
Time-ordered UUIDs for primary keys.
ULID
Sortable, URL-safe identifiers.
TypeID
UUID v7 values with readable type prefixes.
CUID v2
Non-sequential identifiers that resist enumeration.
Nanoid
Compact URL-safe identifiers.
KSUID
High-entropy, time-ordered identifiers.
ObjectID
MongoDB-compatible identifiers.
XID
Compact identifiers compatible with rs/xid.
TSID
Time-sorted bigint identifiers.
Errors
Typed errors and the generator list.