Skip to content

client.offline

See the Offline guide for concepts and patterns. Offline support is on by default in browsers and a no-op in Node/Workers/SSR.

client.offline.status: "online" | "offline" | "syncing"

Current connectivity, fused from navigator.onLine, real request outcomes, and the websocket lifecycle. "syncing" means the durable write queue is draining after a reconnect.

client.offline.enabled: boolean

true in a browser with IndexedDB + the Cache API; false otherwise (all methods become no-ops / return empty).

onStatusChange(cb: (status: "online" | "offline" | "syncing") => void): () => void

Subscribe to connectivity changes. Returns an unsubscribe function. Status changes are also emitted on EventCore (ONLINE, OFFLINE, SYNCING, SYNC_PROGRESS, SYNC_COMPLETE, SYNC_ERROR).

App-state snapshots — client.offline.snapshot

Section titled “App-state snapshots — client.offline.snapshot”

An encrypted, local-only cache for UI/view state. Encrypted at rest with the identity-derived key; reads return null while the client is locked.

save<T>(name: string, state: T): Promise<void>

Persist state under name (encrypted). Throws OfflineLockedError if the identity isn’t unlocked. No-op when offline support is off.

load<T>(name: string): Promise<T | null>

Decrypt and return the snapshot, or null if absent or the client is locked.

delete(name: string): Promise<void>
list(): Promise<string[]>

Remove a snapshot; list all snapshot names for the current user.

Thrown when an encrypted offline read/write needs the user’s identity but the client is locked (typically right after a reload, before unlock()). Distinct from the generic “not signed in” error so apps can prompt to unlock specifically.