@sharyn/nanoid

A Nano ID default configuration with no lookalikes (0, O, 1, l, I), and without - and _.

Usage no npm install needed!

<script type="module">
  import sharynNanoid from 'https://cdn.skypack.dev/@sharyn/nanoid';
</script>

README

🌹 @sharyn/nanoid

A Nano ID default configuration with no lookalikes (0, O, 1, l, I), and without - and _.

To have a risk of collision similar to UUID v4 (149 billion years at 1000 IDs per hour for 1% collision risk on Nano ID Collision Calculator), use a length of 22 (334 billion years), or 21 (44 billion years). The default length used here is 20 (6 billion years), for the only reason that it's a nicer round number, while remaining extremely collision-safe. The age of Earth being 4.5 billion years, I think we're good here.

Installation

npm install --save @sharyn/nanoid
# or
yarn add @sharyn/nanoid

Usage

import id from '@sharyn/nanoid'

id() // '4wEkBX8dJmMrzoXFBgQD'
id(10) // 'uCZij3SEne'

This package is part of Sharyn, a collection of utilities and helpers.