NewSortable IDs are here
prefID
Menu

Comparison

How prefID relates to the ID libraries you already know.

prefID isn't trying to replace uuid or nanoid — it borrows their strengths (secure randomness, zero dependencies) and adds two things neither has: a prefix and a type-safe return value.

PrefixesType-safe prefixSecure RNGDependencies
uuid0
nanoid0
prefID0

Side by side

import { v4 as uuidv4 } from "uuid";
import { nanoid } from "nanoid";
import { id } from "prefid";

uuidv4(); // "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"
nanoid(); // "V1StGXR8_Z5jdHi6B-myT"
id("user"); // "user_a8Kd0f2bQ1nR7pZ3xW4mT6y"  ← self-describing + typed
const { v4: uuidv4 } = require("uuid");
const { nanoid } = require("nanoid");
const { id } = require("prefid");

uuidv4(); // "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"
nanoid(); // "V1StGXR8_Z5jdHi6B-myT"
id("user"); // "user_a8Kd0f2bQ1nR7pZ3xW4mT6y"  ← self-describing

When to use which

  • uuid — you need the formal standard (a Postgres UUID column, interop with other systems, or a time-sortable v7 key).
  • nanoid — you want a short, URL-friendly random string and don't care about prefixes or a standard.
  • prefID — you want readable, self-describing IDs that TypeScript understands: user_..., order_....