DEV Community

Cover image for I published my first npm package: `short-id-lite` πŸŽ‰
Bashar V I
Bashar V I

Posted on

I published my first npm package: `short-id-lite` πŸŽ‰

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"


Enter fullscreen mode Exit fullscreen mode

Top comments (0)