Skip to content
Myr

Fix outdated info and links in README (#566)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

- Update size comparison from 130 to 118 bytes (matches actual size-limit) - Remove duplicate collision calculator link with outdated URL - Use ESM import instead of require() in customRandom example - Update React useId link to react.dev (reactjs.org is legacy)

authored by Mahmoud Hamdy · committed by GitHub · parent e0a3080 · Browse files · 1 file+3 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+3 added−4 removed

  • other:+3 added−4 removed

1 file+3 added−4 removed

modified:README.md+3 added-4 removed
72 unmodified lines
73741. Nano ID uses a bigger alphabet, so a similar number of random bits75 are packed in just 21 symbols instead of 36.762. Nano ID code is **4 times smaller** than `uuid/v4` package:77 130 bytes instead of 423.77 118 bytes instead of 423.787980## Benchmark81
191 unmodified lines
273const nanoid = customAlphabet('1234567890abcdef', 10)274model.id = nanoid(5) //=> "f01a2"275```276277[ID collision probability]: https://alex7kom.github.io/nano-nanoid-cc/277[`nanoid-dictionary`]: https://github.com/CyberAP/nanoid-dictionary278279280### Custom Random Bytes Generator
20 unmodified lines
301If you want to use the same URL-friendly symbols with `customRandom`,302you can get the default alphabet using the `urlAlphabet`.303304```js306const { customRandom, urlAlphabet } = require('nanoid')305import { customRandom, urlAlphabet } from 'nanoid'306const nanoid = customRandom(urlAlphabet, 10, random)307```308309Note, that between Nano ID versions we may change random generator
47 unmodified lines
357In case you just need random IDs to link elements like labels358and input fields together, [`useId`] is recommended.359That hook was added in React 18.360362[`useId`]: https://reactjs.org/docs/hooks-reference.html#useid361[`useId`]: https://react.dev/reference/react/useId362363364### React Native365
134 unmodified lines