search/
Start typing to search packages!
package_2
nanoid
By @stackyzdev
Roblox
MirroredNano ID (Roblox)
A tiny, URL-friendly, unique string ID generator for Roblox (Luau).
This package is a Roblox implementation of Nano ID, the original project by Andrey Sitnik: https://github.com/ai/nanoid
Why Nano ID
- Short IDs: uses the URL-safe alphabet (
A-Za-z0-9_-) style with a compact default size. - Simple API: one function to generate IDs.
- Customizable: supports custom size and custom alphabet.
How It Works
Like the original Nano ID approach, this implementation generates IDs by:
- Choosing an alphabet (default: URL-friendly symbols).
- Picking random characters from that alphabet.
- Repeating until the target length is reached (default:
21).
Security
The original Nano ID emphasizes cryptographic randomness.
In this Roblox version, randomness comes from Random.new().
If you need strict cryptographic guarantees, review your platform constraints and threat model before using generated IDs for security-sensitive use cases.
Defaults
- Default ID size:
21 - Default alphabet: URL-friendly Nano ID alphabet
Collision Notes
Collision probability depends on:
- Alphabet length
- ID size
- Total number of generated IDs
Larger alphabets and longer IDs reduce collision risk.
Usage
Wally
[dependencies]
nanoid = "stackyzdev/nanoid@0.1.0"
Luau
local nanoid = require(path.to.nanoid)
local id = nanoid()
print(id) -- e.g. V1StGXR8_Z5jdHi6B-myT
local shortId = nanoid(10)
print(shortId)
local custom = nanoid(12, "1234567890abcdef")
print(custom)
API
generate(size: number?, alphabet: string?) -> string
size(optional): target length of the ID (default:21)alphabet(optional): characters used to build the ID
Credits
- Original Nano ID by Andrey Sitnik and contributors: https://github.com/ai/nanoid
Package Details
Install command (Click to copy)
Version
0.1.0
License
MIT
Safe for commercial use
Automated license review — not legal advice.
