
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
@uscreen.de/id-generator
Advanced tools
Generate unique, sortable IDs with optional prefixes using ULID
Generate unique, sortable IDs with optional prefixes using ULID.
pnpm add @uscreen.de/id-generator
Or with npm:
npm install @uscreen.de/id-generator
import { generateId, id, newId } from '@uscreen.de/id-generator'
// Generate a basic ID
const basicId = id()
// → '01hmqr8x3jk9v7n8q2m1c4d5f6'
// Generate an ID with a prefix
const userId = id('user')
// → 'user_01hmqr8x3jk9v7n8q2m1c4d5f6'
const orderId = id('order')
// → 'order_01hmqr8x3jk9v7n8q2m1c4d5f7'
// Use aliases (all do the same thing)
const id1 = generateId('product')
const id2 = newId('category')
id(prefix?: string): stringGenerates a unique, sortable ID.
Parameters:
prefix (optional): String prefix to prepend to the ID, separated by underscoreReturns:
generateId(prefix?: string): string - Alias for id()newId(prefix?: string): string - Alias for id()import { id } from '@uscreen.de/id-generator'
// Database records
const userId = id('user') // 'user_01hmqr8x3jk9v7n8q2m1c4d5f6'
const postId = id('post') // 'post_01hmqr8x3jk9v7n8q2m1c4d5f7'
const commentId = id('comment') // 'comment_01hmqr8x3jk9v7n8q2m1c4d5f8'
// File names
const fileName = id('upload') // 'upload_01hmqr8x3jk9v7n8q2m1c4d5f9'
// Session IDs
const sessionId = id('session') // 'session_01hmqr8x3jk9v7n8q2m1c4d5fa'
// No prefix
const simpleId = id() // '01hmqr8x3jk9v7n8q2m1c4d5fb'
ULID combines the best of UUIDs and timestamp-based IDs:
This project maintains 100% test coverage. Run tests with:
pnpm test # Run all tests
pnpm test:cov # Run with coverage report
pnpm test:ci # Run in CI mode
MIT
Marcus Spiegel spiegel@uscreen.de - published, supported and sponsored by u|screen
FAQs
Generate unique, sortable IDs with optional prefixes using ULID
We found that @uscreen.de/id-generator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.