react-native-uuid is a zero-dependency TypeScript implementation of RFC4122 standard A Universally Unique IDentifier (UUID) URN Namespace. Please note, this library uses pseudo random generator based on top of Math.random. New version with hardware support is WIP.
Heavily inspired by:
Huge thanks to Randy Coulman for the early version of a code.
npm install react-native-uuid
import uuid from 'react-native-uuid';
uuid.v4(); // ⇨ '11edc52b-2918-4d71-9058-f7285e29d894'
# Install dependencies
npm install
# Run tests
npm test
npm test -- --watch # Watch mode
npm test -- --coverage # With coverage report
# Linting and formatting
npm run lint # Lint TypeScript and JavaScript
npm run prettier:write # Format all files
npm run prettier:check # Check formatting without changes
# Building
npm run build # Build TypeScript to JavaScript
npm run prepublishOnly # Build before publishing (auto on npm publish)
# Benchmarking
npm run bench:rn # Generate benchmark matrix for RN 0.71 - 0.77
npm run bench:security # Run security benchmark with pass/fail thresholds
# Documentation
npm run docs # Generate TypeDoc documentation
We keep a baseline benchmark matrix for major React Native versions:
v1, v3, v4, v5, validate, parse, unparsebenchmarks/results/rn-version-benchmark.mdbenchmarks/results/rn-version-benchmark.jsonbenchmarks/results/test-results.jsonGenerate fresh results locally:
npm run bench:rn
npm test -- --runInBand --json --outputFile benchmarks/results/test-results.json
npm run bench:security
npm run bench:figures
The security benchmark is designed as a pass/fail gate for randomness quality and misuse safety checks.
npm run bench:securitybenchmarks/results/security-benchmark.mdbenchmarks/results/security-benchmark.json.github/workflows/security-benchmark.ymlCurrent threshold gates:
00<= 4<= 4<= 4200The CI job fails if any threshold is exceeded.
Methods documentation is available here
Previous version has been based on randombytes that is not compatible with react-native out of the box.
Please submit an issue if you found a bug.
See the contributing guide to learn how to contribute to the repository and the development workflow.
Thank you to our sponsors:
Copyright (c) 2016-2026 Eugene Hauptmann