Generates a random RFC 9562 version 7 UUID. The UUID contains a millisecond precision Unix timestamp in the most significant 48 bits, followed by cryptographically secure random bits for the remaining fields, making it suitable for use as a database key with time-based sorting. The embedded timestamp relies on a non-monotonic clock and is not guaranteed to be strictly increasing.
function
crypto.randomUUIDv7
): `${string}-${string}-${string}-${string}-${string}`;
Referenced types
interface RandomUUIDV7Options
- disableEntropyCache?: boolean
By default, to improve performance, Node.js will pre-emptively generate and persistently cache enough random data to generate up to 128 random UUIDs. To generate a UUID without using the cache, set
disableEntropyCachetotrue.