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

crypto-id-lite

v1.0.0

Published

Ultra-fast, zero-dependency cryptographically secure random ID, UUID v4, and token generator using native Web Crypto.

Readme

🔑 crypto-id-lite

Ultra-fast, lightweight (< 1 KB), zero-dependency cryptographically secure random ID, UUID v4, and token generator using native Web Crypto.

npm version License: MIT Sponsor TypeScript Size


💡 Why crypto-id-lite?

Every web application and backend requires unique identifiers for database records, session tokens, API keys, or verification codes. Often teams install both uuid and nanoid simultaneously, pulling separate dependencies and polyfills.

crypto-id-lite provides:

  • ⚡ Zero Dependencies — Minified to less than 1 KB, pure native TypeScript.
  • 🔐 Cryptographically Secure — Powered directly by standard globalThis.crypto.getRandomValues() and randomUUID().
  • 🎛️ All-in-One Generator — Compact NanoIDs, RFC4122 v4 UUIDs, Hex API tokens, and numeric verification PINs in a single package.
  • 🔠 Custom Alphabets — Supply custom characters for lowercase-only, alphanumeric, or hex requirements.
  • 📦 Dual ESM & CommonJS — Works everywhere: Node.js, Next.js, Vite, Remix, React Native, and edge runtimes (Cloudflare Workers, Deno, Bun).

📥 Installation

# npm
npm install crypto-id-lite

# pnpm
pnpm add crypto-id-lite

# yarn
yarn add crypto-id-lite

# bun
bun add crypto-id-lite

🚀 Usage & Real-World Examples

1. NanoID-Style Compact Random IDs

import { generateId } from 'crypto-id-lite';

// Default 21-character URL-safe string:
const userId = generateId();
console.log(userId);
// "V1StGXR8_Z5jdHi6B-myT"

// Custom length:
const shortId = generateId(10);
console.log(shortId);
// "75pxJACKVE"

// Custom alphabet (e.g. lowercase alphanumeric):
const slug = generateId(8, '0123456789abcdefghijklmnopqrstuvwxyz');
console.log(slug);
// "k8v2q9m1"

2. Standard RFC4122 Version 4 UUIDs

import { generateUuid } from 'crypto-id-lite';

const transactionId = generateUuid();
console.log(transactionId);
// "f47ac10b-58cc-4372-a567-0e02b2c3d479"

3. Secure Hex Tokens for Password Resets & API Keys

import { generateHexToken } from 'crypto-id-lite';

// Generates 32 bytes (64 hex characters) secure secret token:
const resetPasswordToken = generateHexToken(32);
console.log(resetPasswordToken);
// "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"

4. Numeric OTP / Verification PINs

import { generatePin } from 'crypto-id-lite';

// Generates 6-digit numeric SMS / Email verification code:
const smsOtp = generatePin(6);
console.log(smsOtp);
// "491823"

📖 API Reference

generateId(size?, alphabet?)

Generates a cryptographically secure random string with uniform character distribution.

  • Parameters:
    • size (number, default: 21): Desired string length.
    • alphabet (string, default: URL-safe 64-char alphabet): Set of characters to choose from.
  • Returns: string

generateUuid()

Generates a standard 36-character RFC4122 compliant version 4 UUID.

  • Returns: string (e.g. xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx)

generateHexToken(byteLength?)

Generates a cryptographically random hexadecimal string.

  • Parameters:
    • byteLength (number, default: 32): Entropy byte count (resulting string length will be byteLength * 2).
  • Returns: string

generatePin(length?)

Generates a random numeric string (digits 0-9).

  • Parameters:
    • length (number, default: 6): Number of digits.
  • Returns: string

💖 Support the Project

If crypto-id-lite replaced bloated ID dependencies in your projects, please consider sponsoring:

👉 Sponsor @Piratha97 on GitHub Sponsors


📄 License

MIT © 2026 Pirapaakaran Pirathapan