Skip to main content

Function: uniqueId()

uniqueId(length?): string

Defined in: base/common.ts:22

Generates a random ID string.

The generated ID is URL-safe, using only lowercase letters and numbers. The default length of 24 characters provides a large enough space to ensure a very low probability of collisions for most applications.

Note: This function uses Math.random() which is not cryptographically secure. Do not use for security-sensitive purposes.

With 36 possible characters (a-z, 0-9) and a length of 24, there are 36^24 (approximately 2.24 * 10^37) possible unique IDs, making collisions extremely unlikely for most use cases.

Parameters

ParameterTypeDefault valueDescription
lengthnumber24The length of the ID to generate (default: 24)

Returns

string

A random string of the specified length