What it is
Nano ID is a small convention for random identifiers: 21 characters from a 64-character URL-safe alphabet (A-Za-z0-9_-, in the library's own scrambled order), giving 126 bits of entropy. That is essentially the same strength as a UUID v4's 122 bits in 21 characters instead of 36, with no hyphens and nothing that needs escaping in a URL, a filename or a DOM id.
When it's the right choice
Use it when an identifier will be visible — in a URL, in a share link, in an element id — and you want it short and unguessable. Use a UUID instead when something else expects one: a database uuid column, an API contract, a spec. Nano ID has no standard behind it, which is the honest trade: you get a shorter string and you give up the guarantee that every other system knows what to do with it.
On collisions and on the alphabet
At 21 characters the collision risk is a non-issue — you would need to generate roughly 1.3 × 10¹⁸ independent IDs to reach roughly a 1% collision probability. Shortening is where care is required: each character you remove costs 6 bits, so a 10-character Nano ID has 60 bits and collisions become realistic at scale. The odd-looking default alphabet (useandom-26T198340PX75px...) is not random-looking for effect; it is the library's fixed ordering, and reproducing it exactly is what makes these interchangeable with what npx nanoid emits. As everywhere on this site, characters are drawn with rejection sampling, so every one is equally likely — the library does the same thing, and for the same reason.