Rethinking Unique Identifiers: Exploring NanoID as an Alternative to UUIDs

Prabesh
7 min readMar 31, 2024

Yesterday, I was chatting with a friend about how he does API design. We were discussing how he approaches designing an API. Here is the link to that video: https://www.youtube.com/live/bcc8Nad77RM?si=-zWB1wWqcdcN2mZW

Anyway, one thing that stood out to me was his reliance on UUIDs for unique identifiers. Which let me write this article down. Everyone works differently, I understand this however, If you have read my previous blog on UUID then you know that I don’t like UUID. At least how they are thrown around. Here is the link: https://99devops.com/why-i-do-not-like-uuid/

As someone with a keen interest in cryptography and randomness, I got curious: is there a better way of doing this? After all, the core function of UUIDs is to guarantee unique identification for objects. That’s it.

Before we begin, let’s talk a bit about randomness.

The Illusion of True Randomness

True randomness is a mathematical fantasy. We can strive for it, but as the sample space increases, patterns start to emerge. That’s the nature of our universe. I wrote more about the difficulty of achieving true randomness here…

--

--

Prabesh

Senior Site Reliability Engineer & Backend Engineer | Docker Captain 🐳 | Auth0 Ambassador @Okta | https://www.linkedin.com/in/prabeshthapa