Skip to content

fungi-computer/shiit-id

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@shiit/id

Minimal nanoid wrapper using Crockford's base32 alphabet.

Why

Nanoid's default alphabet includes characters that can be confused when reading codes aloud (e.g., l vs 1, O vs 0). This package uses the Crockford base32 alphabet which avoids these ambiguities.

Installation

npm install @shiit/id

Usage

import { nanoid, ALPHABET_CROCKFORD, SHORT, DEFAULT, LONG } from "@shiit/id";

// Default length (21 characters)
nanoid(); // e.g., "V3X7Pz9QG3B8WFMKTN2HW"

// Short ID (8 characters)
nanoid(SHORT); // e.g., "V3X7Pz9Q"

// Long ID (32 characters)
nanoid(LONG); // e.g., "V3X7Pz9QG3B8WFMKTN2HWV3X7Pz9QG3B8"

// Custom length
nanoid(12); // e.g., "V3X7Pz9QG3B"

API

nanoid(length?: number): string

Generates a unique ID using Crockford's base32 alphabet.

  • length: Optional length (defaults to 21)
  • Returns: A URL-safe unique string

Constants

  • ALPHABET_CROCKFORD: The Crockford base32 alphabet used
  • SHORT: 8 (for short IDs)
  • DEFAULT: 21 (default length)
  • LONG: 32 (for long IDs)

License

MIT

Releases

Packages

Contributors

Languages