A UUID is a 128-bit identifier that avoids collisions by having an enormous value space rather than by coordinating with anyone. The practical payoff is that a client can mint its own primary key while completely offline, without asking a database, and several services can write concurrently without clashing. The cost is that it is far longer than an auto-increment integer and carries no ordering information.
The versions solve different problems. v4 is pure randomness and fits almost every case. v7 puts a millisecond timestamp in the high bits, so sorting the strings sorts by creation time; which matters a great deal to database indexes. v1 also carries time, but writes the MAC address into the identifier and therefore leaks information about the machine. NanoID is not a UUID at all: it trades a different alphabet for a shorter string, which is what you want in a URL.
Generation uses the browser's `crypto.getRandomValues()`; the operating system's cryptographically secure random source, not `Math.random()`. That distinction matters whenever an identifier is treated as something hard to guess.