Reference
CUID v2
Non-sequential, string-native identifiers that resist enumeration.
CUID v2 is for public values where predictability is the problem. It is string-native, so there is no byte codec to maintain or expose.
import { cuidv2 } from 'uniku/cuid/v2'
const inviteId = cuidv2()
// 'rqa97fgr3wexenbnth08ihdk' (string)Generated API reference
Public methods
Generate a CUID v2 string. CUID v2 is a secure, collision-resistant identifier that hashes multiple entropy sources using SHA3-512. Unlike time-ordered IDs (ULID, UUID v7), CUID v2 prevents enumeration attacks by making IDs non-predictable. Note: CUID v2 does not provide toBytes/fromBytes because it is a string-native format with no canonical binary representation (unlike UUID's 16-byte format).
- cuidv2
Generate a CUID v2 string.
cuidv2(options?: Cuid2Options): stringExamplecuidv2()// => 'rqa97fgr3wexenbnth08ihdk'- isValid
Return whether a value is a syntactically valid CUID v2 string.
isValid(id: unknown): id is stringExamplecuidv2.isValid('rqa97fgr3wexenbnth08ihdk')// => true