DB Docs
API Reference
- Core API Reference
- Collection
- createCollection
- liveQueryCollectionOptions
- createLiveQueryCollection
- createOptimisticAction
- createTransaction
- Electric DB Collection
- electricCollectionOptions
- Query DB Collection
- queryCollectionOptions
- RxDB DB Collection
- rxdbCollectionOptions
- PowerSync Collection
- powerSyncCollectionOptions
- createIndexedDB
- indexedDBCollectionOptions
- React Hooks
- useLiveQuery
AI/LLM: This documentation page is available in plain markdown format at/db/latest/docs/reference/functions/safeRandomUUID.md
safeRandomUUID
ts
function safeRandomUUID(): string;Defined in: packages/db/src/utils/uuid.ts:13
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