Home / Companies / PlanetScale / Blog / Post Details
Content Deep Dive

Why we chose NanoIDs for PlanetScale’s API

Blog post from PlanetScale

Post Details
Company
Date Published
Author
Mike Coutermarsh
Word Count
871
Company Posts That Month
6
Language
English
Hacker News Points
79
Post removed?
No
Summary

When building PlanetScale's API, the team needed a unique identifier that wouldn't reveal record counts in tables, avoiding the use of integer IDs. They considered using UUIDs but found they took up too much space in URLs. To address this, they developed NanoIDs, which are shorter than UUIDs, easy to select with double-clicking, and have a low chance of collisions. The team used 12-character long IDs with a specific alphabet, resulting in a 1% probability of collision over ~35 years if generating 1000 IDs per hour. To generate NanoIDs, they added a public_id column to their database schema for public-facing models and built a concern that could be shared across all models to auto-generate IDs. The same approach was applied in their Go backend service, using a package called go-nanoid/v2 to generate unique public IDs. By solving this detail, PlanetScale aimed to create a great developer experience.

Trends Found in this Post
Trend Post Mentions Total Month Mentions Posts Companies MoM
Developer Experience 2 286 114 64 +43%
Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.