Creates a cryptographically secure UID with a 62 character range that can be safely used in URLs.
Install the package:
npm i uid-promiseThen import it:
import { uid } = from 'uid-promise';Finally, call it:
await uid(20);uid(Number len) => Promise
- Return a Promisethat resolves with a string of random characters of lengthlen
- lenmust always be provided, else the promise is rejected
- Under the hood, crypto.randomBytesis used
- Character set: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
- Guillermo Rauch (@rauchg) - Vercel
- Leo Lamprecht (@notquiteleo) - Vercel