prefID generates type-safe, prefixed IDs like user_a1b2c3 with zero dependencies. Secure, tiny, and universal with distributed ID support. With more control than UUID.
No reviews yetBe the first to leave a review for prefID
Maker
📌
Hi everyone! Thanks for checking out prefID.
I built prefID because I kept needing clean, prefixed IDs like user_xxx, order_xxx, and invoice_xxx across different projects. While libraries like UUID and NanoID are excellent, I found myself repeatedly writing custom logic to add prefixes, keep IDs consistent, and support different ID formats.
So I built prefID which is likee a lightweight, zero-dependency library for generating prefixed IDs with multiple generation strategies.
Key features:
Zero dependencies
Cryptographically secure random IDs
Sortable IDs for time-ordered data
Distributed-system friendly ID generation
Built-in prefixes (user_, order_, invoice_, etc.)
URL-safe output
Custom prefixes, separators, length, and alphabets
Full TypeScript support
Works in Node.js, Bun, Deno, and modern browsers
Example:
import { id, sid } from "prefid";
id("user"); // user_F7kP3Qn2...
sid("order"); // order_01K4...
Whether you're building APIs, databases, event-driven systems, or distributed applications, prefID aims to make ID generation simple, consistent, and flexible.
I'd genuinely love your feedback on the API, documentation, performance, or feature ideas. If there's something you'd like to see added, let me know!
Thanks for taking the time to check it out, and I hope prefID makes your next project a little easier.
Report
💡 Bright idea
Love the zero-dependency approach and the prefixed format makes debugging so much easier than raw UUIDs. One thing I'd love to see is a built-in parser that can take a prefixed ID and return both the prefix and raw ID separately, so I don't have to write that regex every time.
Report
Maker
@aminet52n yeah good addition . thanks . Also do you know how can i make a npm package a bit famous like known to a good amount of people ?
Love the zero-dependency approach and the prefixed format makes debugging so much easier than raw UUIDs. One thing I'd love to see is a built-in parser that can take a prefixed ID and return both the prefix and raw ID separately, so I don't have to write that regex every time.
@aminet52n yeah good addition . thanks . Also do you know how can i make a npm package a bit famous like known to a good amount of people ?