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

safeRandomUUID.md

23 lines599 Bytes

1---
2id: safeRandomUUID
3title: safeRandomUUID
4---
5​
6```ts
7function safeRandomUUID(): string;
8```
9​
10Defined in: [packages/db/src/utils/uuid.ts:11](https://github.com/TanStack/db/blob/main/packages/db/src/utils/uuid.ts#L11)
11​
12Returns a RFC 4122 version 4 UUID.
13​
14Prefers `crypto.randomUUID()` when available. In non-secure browser contexts
15(e.g. a dev server accessed via a LAN IP over HTTP) `crypto.randomUUID` is
16`undefined`, so this falls back to building a UUIDv4 from
17`crypto.getRandomValues`. Throws if neither API is available.
18​
19See https://github.com/TanStack/db/issues/1541.
20​
21## Returns
22​
23`string`