[6a3a178] | 1 | # Nano ID
|
---|
| 2 |
|
---|
| 3 | <img src="https://ai.github.io/nanoid/logo.svg" align="right"
|
---|
| 4 | alt="Nano ID logo by Anton Lovchikov" width="180" height="94">
|
---|
| 5 |
|
---|
| 6 | **English** | [Русский](./README.ru.md) | [简体中文](./README.zh-CN.md)
|
---|
| 7 |
|
---|
| 8 | A tiny, secure, URL-friendly, unique string ID generator for JavaScript.
|
---|
| 9 |
|
---|
| 10 | > “An amazing level of senseless perfectionism,
|
---|
| 11 | > which is simply impossible not to respect.”
|
---|
| 12 |
|
---|
[e29cc2e] | 13 | * **Small.** 130 bytes (minified and gzipped). No dependencies.
|
---|
[6a3a178] | 14 | [Size Limit] controls the size.
|
---|
| 15 | * **Fast.** It is 2 times faster than UUID.
|
---|
| 16 | * **Safe.** It uses hardware random generator. Can be used in clusters.
|
---|
| 17 | * **Short IDs.** It uses a larger alphabet than UUID (`A-Za-z0-9_-`).
|
---|
| 18 | So ID size was reduced from 36 to 21 symbols.
|
---|
| 19 | * **Portable.** Nano ID was ported
|
---|
| 20 | to [19 programming languages](#other-programming-languages).
|
---|
| 21 |
|
---|
| 22 | ```js
|
---|
| 23 | import { nanoid } from 'nanoid'
|
---|
| 24 | model.id = nanoid() //=> "V1StGXR8_Z5jdHi6B-myT"
|
---|
| 25 | ```
|
---|
| 26 |
|
---|
| 27 | Supports modern browsers, IE [with Babel], Node.js and React Native.
|
---|
| 28 |
|
---|
| 29 | [online tool]: https://gitpod.io/#https://github.com/ai/nanoid/
|
---|
| 30 | [with Babel]: https://developer.epages.com/blog/coding/how-to-transpile-node-modules-with-babel-and-webpack-in-a-monorepo/
|
---|
| 31 | [Size Limit]: https://github.com/ai/size-limit
|
---|
| 32 |
|
---|
| 33 | <a href="https://evilmartians.com/?utm_source=nanoid">
|
---|
| 34 | <img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg"
|
---|
| 35 | alt="Sponsored by Evil Martians" width="236" height="54">
|
---|
| 36 | </a>
|
---|
| 37 |
|
---|
| 38 | ## Docs
|
---|
| 39 | Read **[full docs](https://github.com/ai/nanoid#readme)** on GitHub.
|
---|