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.
Properties
Section titled “Properties”status
Section titled “status”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.
enabled
Section titled “enabled”client.offline.enabled: booleantrue in a browser with IndexedDB + the Cache API; false otherwise (all
methods become no-ops / return empty).
Methods
Section titled “Methods”onStatusChange(cb)
Section titled “onStatusChange(cb)”onStatusChange(cb: (status: "online" | "offline" | "syncing") => void): () => voidSubscribe 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(name, state)
Section titled “save(name, state)”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(name)
Section titled “load(name)”load<T>(name: string): Promise<T | null>Decrypt and return the snapshot, or null if absent or the client is locked.
delete(name) / list()
Section titled “delete(name) / list()”delete(name: string): Promise<void>list(): Promise<string[]>Remove a snapshot; list all snapshot names for the current user.
Related
Section titled “Related”space.cachedMessages()— decode the locally-cached message log (offline hydrate).- The
offlineoption onnew Client(...)— enable/disable or supply a custom store.
Errors
Section titled “Errors”OfflineLockedError
Section titled “OfflineLockedError”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.