SyncProvider. They re-render automatically whenever the relevant slice of store state changes.
useSyncStatus()
Returns the live SyncStatus object. Use it to show loading states, connection indicators, and pending mutation counts. The component re-renders whenever any status field changes.
useSyncCollection(definition, args?)
Subscribes to a collection slice and returns the sorted record array. Returns undefined while the store has never loaded this slice (distinct from [], which means the server confirmed it’s empty). Pass query arguments when your collection uses deriveKey.
useSyncRecord(collection, id?)
Subscribes to a single record by collection name and string ID. Returns undefined if the record isn’t in the cache or if id is undefined (handy for optional IDs from route params).
useSyncMutation(definition)
Returns a stable callback that calls store.enqueueMutation when invoked. The callback applies the optimistic reducer immediately and returns a promise that resolves with the flush result (or undefined if no flush is defined).
useHydratedValue(localValue, serverValue)
A utility hook for server-rendering patterns. Returns:
serverValueif it is non-nullish (server data is authoritative)localValueif the store is hydrated (IndexedDB data is ready)undefinedif neither is available yet
useSyncStore()
Returns the raw SyncStore instance from context. Use this for advanced patterns that need direct store access outside the higher-level hooks.
useSyncSelector(selector)
Subscribes to store changes and returns the result of selector(store). The component re-renders only when the selector’s return value changes (by reference equality). Use this for custom derived state that doesn’t map directly to a single collection or record.
useSyncSelector re-runs the selector on every store emission. Keep selectors cheap — avoid allocating new arrays or objects inside the selector unless you memoize with useMemo.