Sweet ID
Alphanumeric IDs, powered by Nano ID
Quick Start
Import sweetid() directly into your project.
import { sweetid } from "https://deno.land/x/sweetid/mod.ts";
sweetid();
// => CUXuq1Or use Sweet ID in the command line.
deno run https://deno.land/x/sweetid/mod.ts
# buGdUoDetails
We use Nano ID under the hood to guarantee high-quality, cryptographically secure IDs.
Sweet ID are alphanumeric and always start with a letter.
ID Length
The sweetid() function generates IDs with a length 6, 12, 18, or 24
characters. IDs are 6 characters long by default.
Pass in an optional SweetIdSize as the first argument to set
the output size of the ID.
sweetid("small" || "s");
// => hBuWX4
sweetid("medium" || "m");
// => b1eOHzXq6iK0
sweetid("long" || "l");
// => Rk3ulcSjeoyigV1zYn
sweetid("xlong" | "x");
// => CYhSN6DvdNZajwKhDjmdFXADPass in the same SweetIdSize as an optional flag to set the output size on the
command line.
deno run https://deno.land/x/sweetid/mod.ts --small || -s
# PLmh1V
deno run https://deno.land/x/sweetid/mod.ts --medium || -m
# so24iHcuI86i
deno run https://deno.land/x/sweetid/mod.ts --long || -l
# lugJNFIFYYLWJ8SAnb
deno run https://deno.land/x/sweetid/mod.ts --xlong || -x
# NsiHnUqK3cbADQ9cIzsi0Og0TypeScript Types
Use SweetId and SweetIdSize to add type info
to your project. This is great for things like custom wrapper functions.
import type {
SweetId,
SweetIdSize,
} from "https://deno.land/x/foo/bar/baz@v0.0.4/mod.ts";
import { sweetid } from "https://deno.land/x/foo/bar/baz@v0.0.4/mod.ts";
export function customSweetId(size: SweetIdSize = "medium"): SweetId {
return sweetid(size);
}***NOTE: SweetId is a
flexible nominal type
and will play nicely with generic string types if needed.