uuid
Generates standard UUID variants and provides parsing, validation and version checks.
- Downloads / mo
- 1.5B
- Stars
- 15.3K
- Last release
- 14.0.3
- License
- MIT
Strengths
- Generates reordered timestamp UUIDs. Choose a reordered timestamp variant when ID ordering matters.
- Checks UUID version constraints. Combine validate and version when a field requires a specific UUID version.
Limitations
- Current releases require ES modules. CommonJS imports are unsupported in current uuid releases.
- Options bypass timestamp generator state. Passing options disables the internal timestamp-UUID state.
Quickstart
import { v4 as uuidv4 } from 'uuid'; console.log(uuidv4());
uuid examples
export function generateId(prefix?: string) { const id = uuidv4().replace(/-/g, ''); if (prefix) { return `${prefix}_${id}`; } return id; }