UUIDv7 generator based on the RFC4122 update proposal (draft-04)
import { uuidv7 } from "@kripod/uuidv7";
let id = uuidv7();
console.log(id); // Example: 00ccebbc-13e0-7000-8b18-6150ad2d0c05
Chrome | Safari | Firefox | IE | Node.js | Deno |
---|---|---|---|---|---|
≥57 | ≥10 | ≥48 | No (polyfillable) | ≥8 | ≥1 |
Included in popular frameworks:
Next.js
Nuxt
Gatsby
Polyfillable using core-js, preferably within <script nomodule>
:
import "core-js/features/string/pad-start";
if (typeof window !== "undefined" && !window.crypto && window.msCrypto) {
window.crypto = window.msCrypto;
}
unix_ts_ms
: Milliseconds elapsed since the Unix epoch – 48 bitsver
: UUID version (7
) – 4 bitsrand_a
: Monotonic sequence counter for more precise sorting – 12 bitsvar
: UUID variant (0b10
) – 2 bitsrand_b
: Cryptographically strong random data – 62 bits