nanoid
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
NanoID is a compact, secure, URL-friendly, unique string ID generator developed for JavaScript. It's recognized for its remarkable sense of flawless detail, exhibiting a level of perfectionism that's impossible not to admire. Despite its small size - just 130 bytes when minified and gzipped - it offers impressive features. It is safe, utilizing a hardware random generator so it can be used in clusters. Additionally, by using a larger alphabet than UUID (A-Za-z0-9_-
), it manages to reduce the ID size from 36 to 21 symbols. Notably, it has been ported to more than 20 programming languages, making it incredibly versatile.
Using NanoID is relatively simple and straightforward. First, you need to import the nanoid
function from the nanoid package. Afterwards, you can use the nanoid()
function to generate a unique string ID. An example of its usage is demonstrated below:
import { nanoid } from 'nanoid'
model.id = nanoid() //=> "V1StGXR8_Z5jdHi6B-myT"
In the above code, nanoid
is generating a new unique ID that is assigned to model.id
.
The full documentation of NanoID can be found on its GitHub page. There, you can find more detailed information about its features, usage, API description, and more.