A tiny, secure short ID generator for Node.js β feedback welcome
Publishing your first npm package is oddly intimidating.
You keep asking yourself:
- βIs this useful enough?β
- βAm I reinventing the wheel?β
- βWill anyone actually use this?β
Last week, I decided to stop overthinking and ship something small, focused, and honest.
That package is short-id-lite.
π GitHub repo: https://github.com/BasharVI/short-id-lite
π npm package: https://www.npmjs.com/package/short-id-lite
The problem I kept running into
In almost every backend project, you eventually need short IDs:
- invite codes
- public-facing references
- temporary tokens
- human-friendly identifiers
Not UUIDs. Not database IDs.
Just short, random, URL-safe strings.
So naturally, you reach for existing solutions.
And hereβs the friction I kept feeling
UUIDs
Too long, not human-friendly, overkill for many use cases.Math.random-based helpers
Easy to write, but not safe. Collision risk, predictability issues.-
Fully featured libraries (like nanoid)
Excellent libraries β but sometimes:- more options than I need
- more surface area than I want
- more code to audit for very small use cases
In many projects, I just wanted:
βGive me a short, safe ID. No config. No decisions.β
Why I created short-id-lite
I wanted a package that was:
- Extremely small
- Dependency-free
- Crypto-safe
- Boring in the best way
- Easy to audit
- Stable for years
So I built exactly that β and nothing more.
This is not meant to replace nanoid.
Itβs meant to cover the 80% case with 10% complexity.
What short-id-lite does
- Generates short, URL-safe IDs
- Uses Node.js crypto (
crypto.randomBytes) - Has one function
- No configuration objects
- No mutable global state
- No browser support
- No magic
Example
ts
import { shortId } from "short-id-lite";
shortId(); // e.g. "aZ3F9q"
shortId(10); // e.g. "Qm9KfP2aXz"
Top comments (0)