🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

uniku

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uniku

Minimal, tree-shakeable unique ID generators for every JavaScript runtime

Source
npmnpm
Version
0.4.2
Version published
Weekly downloads
20K
9.89%
Maintainers
1
Weekly downloads
 
Created
Source

uniku

npm version npm downloads CI Documentation License: MIT

One library. Every ID format. Every modern JavaScript runtime.

uniku /uˈniːku/ — Maltese for "unique"

Documentation · Getting started · Choosing an ID · API reference · CLI

import { uuidv7 } from 'uniku/uuid/v7'

const id = uuidv7()
// => "018e5e5c-7c8a-7000-8000-000000000000"

Why uniku?

  • One focused package — UUID v4/v7, ULID, TypeID, CUID v2, Nanoid, KSUID, ObjectID, XID, and TSID.
  • Portable by default — Runs on Node.js, Bun, Deno, browsers, edge runtimes, and Cloudflare Workers using globalThis.crypto.
  • Tree-shakeable entry points — Import only the generator you use; the package root is intentionally not exported.
  • Useful at system boundaries — Validate unknown input, convert canonical binary formats to bytes, or write directly into a caller-owned buffer.
  • Small dependency surface — CUID v2 is the only generator with a runtime dependency (@noble/hashes).

Install

npm install uniku

The getting-started guide also covers pnpm, Bun, and Deno.

Quick start

Every generator has its own entry point and keeps related operations on the generator function:

import { uuidv7 } from 'uniku/uuid/v7'

const id = uuidv7()
const bytes = uuidv7.toBytes(id)
const restored = uuidv7.fromBytes(bytes)

if (uuidv7.isValid(restored)) {
  console.log(uuidv7.timestamp(restored))
}

There are no barrel exports:

import { uuidv4 } from 'uniku/uuid/v4'
import { ulid } from 'uniku/ulid'
import { typeid } from 'uniku/typeid'
import { cuidv2 } from 'uniku/cuid/v2'
import { nanoid } from 'uniku/nanoid'
import { ksuid } from 'uniku/ksuid'
import { objectid } from 'uniku/objectid'
import { xid } from 'uniku/xid'
import { tsid } from 'uniku/tsid'

Choose an ID

SituationStart withWhy
Database primary keysUUID v7 or ULIDTime-ordered values improve index locality
Public API resourcesTypeIDUUID v7 with a readable, domain-specific prefix
Short URLs and invite codesNanoidCompact and URL-safe
Values that should resist enumerationCUID v2Non-sequential and secure
MongoDB _id compatibilityObjectIDMatches MongoDB's 12-byte ObjectID format
Go rs/xid compatibilityXIDMatches rs/xid's text and binary representation
Native BIGINT storageTSIDA sortable 64-bit integer rather than a UUID-shaped string
Broad standards compatibilityUUID v4The conventional random UUID format

The choosing guide covers ordering, timestamp leakage, storage boundaries, and format-specific trade-offs.

Documentation

CLI companion

@uniku/cli generates, validates, and inspects IDs from a terminal or shell pipeline. Install the current standalone binary:

curl -fsSL https://raw.githubusercontent.com/jkomyno/uniku/main/install.sh | sh

uniku uuid -v 7
uniku validate 018e5e5c-7c8a-7000-8000-000000000000
uniku inspect 018e5e5c-7c8a-7000-8000-000000000000

See the CLI documentation for package-manager installs and the complete command reference.

Contributing

See CONTRIBUTING.md for the development workflow, tests, benchmarks, and preview releases.

License

MIT © Alberto Schiabel

Keywords

uuid

FAQs

Package last updated on 15 Jul 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts