Skip to content

Unique IDs (UUID)

SyncJS provides three different functions to generate unique identifiers, each with a different format and use case.

Functions

ShortUID

ts
function ShortUID(): string;

Generates a short, URL-safe unique ID string.

Example:

ts
var uid = ShortUID();
// Example: "Rp68VrvHMNcc5jffKdQaWZ"

LongUID

ts
function LongUID(): string;

Generates a longer, URL-safe unique ID string for cases where even lower collision probability is desired.

Example:

ts
var uid = LongUID();
// Example: "oUhCu6wp6DrmyVxVaEHjzRvv3mh3PGNksSUngbX6rd6Q"

UUIDv4

ts
function UUIDv4(): string;

Generates a standard RFC 4122 version 4 UUID string.

Example:

ts
var uid = UUIDv4();
// Example: "0d2b0018-cc08-44b3-bdc1-401b2819cef1"

NOTE

All three functions return a string containing a unique identifier. Choose the function that best fits your requirements for length, format, and uniqueness.