npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

localuid

v1.0.2

Published

A high-performance, cryptographically secure utility for generating clean, URL-friendly identifiers. Optimized for Bun and TypeScript environments.

Readme

A high-performance, cryptographically secure utility for generating clean, URL-friendly identifiers. Optimized for Bun and TypeScript.

localuid was designed to provide identifiers that are simultaneously robust enough for database primary keys and clean enough for public-facing URLs. localuid can be used for generating table IDs, short-links like /1234kshdi, or meeting-style access codes, localuid provides a secure, collision-resistant solution.

NPM Downloads NPM Monthly Downloads NPM Weekly Downloads

Bundle Size Dependencies TypeScript Runtime

Build Status CI Status Snyk Security Security Score

GitHub stars GitHub forks

Features

  • URL-Friendly: Generates identifiers that are easy to read, type, and share.
  • Cryptographically Secure: Powered by CSPRNG (via globalThis.crypto) for non-deterministic randomness.
  • Collision Resistant: Designed with entropy in mind to ensure uniqueness across large datasets.
  • Beautiful Numbers: Numeric outputs automatically avoid leading zeros, ensuring they remain valid mathematical representations.
  • Strictly Typed: Minimalistic and robust TypeScript interfaces.

Installation

bun add localuid
# or
npm install localuid

Usage

import { localuid } from "localuid";

// 1. Generate numeric IDs (Ideal for Table IDs)
// Ensures no leading zeros. Example: "12378690"
const tableId = localuid.number({ length: 8 });

// 2. Generate alphabetic identifiers (a-z, A-Z)
// Example: "aphens"
const fragment = localuid.alpha({ length: 6 });

// 3. Generate alphanumeric values (0-9, a-z, A-Z)
// Ideal for URL slugs. Example: "456980an"
const urlParam = localuid.alphanumeric({ length: 10 });

// 4. Custom Charsets
// Create human-friendly codes by excluding look-alike characters
const code = localuid.custom({ length: 6 }, "ABCDEFGHJKLMNPQRSTUVWXYZ23456789");

The Mathematics of localuid

Understanding the probability of a collision (two identical IDs being generated) is vital for system integrity.

Keyspace Calculation

The total number of unique possibilities () is calculated as , where is the character set size and is the length.

  • Numeric (number): (Length 13 = 10 Trillion possibilities)
  • Alpha (alpha): (Length 10 = 144 Trillion possibilities)
  • Alphanumeric (alphanumeric): (Length 10 = 839 Quadrillion possibilities)

Collision Probability (Birthday Paradox)

The following table estimates the number of IDs () you can generate before reaching a 1% chance of a single collision occurring in your system.

| Method | Length ($L$) | Total Pool ($N$) | 1% Collision Risk at ($k$) | | ---------------- | ------------ | ---------------- | -------------------------- | | Numeric | 8 | $10^8$ | ~1,417 IDs | | Numeric | 13 | $10^{13}$ | ~450,000 IDs | | Alphanumeric | 10 | $62^{10}$ | ~130,000,000 IDs | | Alphanumeric | 13 | $62^{13}$ | ~20,000,000,000 IDs |

Recommendation: For long-term uniqueness in distributed systems, use alphanumeric with a length of 10+ or number with a length of 13.


API Reference

.number({ length: number })

Generates a string of digits (0-9).

  • Constraints: Length must be between 6 and 13.
  • Safety: Automatically prevents leading zeros.

.alpha({ length: number })

Generates a string of letters [a-z, A-Z].

.alphanumeric({ length: number })

Generates a string of letters and digits [a-z, A-Z, 0-9].

.custom({ length: number }, charset: string)

Generates an ID using a user-provided character set. Use this to exclude confusing characters (e.g., 0, O, I, l) for codes that need to be manually typed by users.


Development & Testing

Built with Bun for maximum performance.

# Install dependencies
bun install

# Run secure test suite
bun test

# Build production artifacts
bun run build

License

MIT