Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

safeRandomUUID.md

25 lines629 Bytes

Function: safeRandomUUID()

function safeRandomUUID(): string;

Defined in: packages/db/src/utils/uuid.ts:11

Returns a RFC 4122 version 4 UUID.

Prefers crypto.randomUUID() when available. In non-secure browser contexts (e.g. a dev server accessed via a LAN IP over HTTP) crypto.randomUUID is undefined, so this falls back to building a UUIDv4 from crypto.getRandomValues. Throws if neither API is available.

See https://github.com/TanStack/db/issues/1541.

Returns

string