ai / nanoid

A tiny (124 bytes), secure, URL-friendly, unique string ID generator for JavaScript
https://zelark.github.io/nano-id-cc/
MIT License
24.22k stars 790 forks source link

Is it possible to create a single js file to import in a company inner project? #482

Closed cydside closed 2 months ago

cydside commented 2 months ago

Hi, I'm a newbie and writing vanilla javascript so could you please let me know, if I missed something in this project home page, how to do a single js file to use it just including <script src="/public/js/nanoid.js"></script> in the html source code? Thanks in advance, Danilo

ai commented 2 months ago

Here is the solution:

import { nanoid } from 'https://cdn.jsdelivr.net/npm/nanoid/nanoid.js'

Put it to your vanilla JS and browser will download the file.

Not only that it is slow for end-users. Use it only for hacks and development.

cydside commented 2 months ago

Thanks! Just last think...How can I add a custom alphabet?

ai commented 2 months ago

Use:

import { customAlphabet } from 'https://cdn.jsdelivr.net/npm/nanoid/index.browser.js'
cydside commented 2 months ago

Got it, many many thanks!