What is a UUID?
A UUID (Universally Unique Identifier) is a 128-bit value written as 36 hexadecimal characters, like 3f2504e0-4f89-41d3-9a0c-0305e82c3301. UUIDs let independent systems create identifiers without coordination — no central counter, with a small but nonzero collision probability. They are standardized by RFC 9562.
UUID v4 vs UUID v7
UUID v4 is fully random: 122 of its 128 bits come straight from the CSPRNG. It's the default choice when identifiers must be unpredictable — API keys' public ids, tokens in URLs, anything a user might see.
UUID v7 starts with a 48-bit Unix timestamp in milliseconds followed by 74 random bits. Because values generated later sort later, v7 keys keep B-tree indexes compact and make excellent database primary keys — inserts stay append-mostly instead of scattering across index pages, a well-known performance issue with v4 primary keys in PostgreSQL and MySQL. The trade-off: a v7 UUID reveals its creation time, so don't use it where that timestamp is sensitive.
How they're generated here
All random bits come from crypto.getRandomValues(); the version and variant bits are set per RFC 9562. Generation is entirely client-side — generate up to 50 at once and copy the whole list.