register()
Registers one store against Flux — IDB caching, realtime updates, the offline write queue, and job tracking all attach to a store through this one call. Everything else in Flux is built on top of what you configure here.
- flux created via createFlux() — see api/create-flux
- A state manager store — Zustand natively, or a Redux/Jotai adapter
Basic usage
flux.register() once per store, typically at module scope alongside the store definition itself — not inside a component body. It returns a cleanup function.Register stores at import time, next to where the store itself is defined. If a registration needs to come and go with a component's lifetime (rare — most stores live for the whole session), call register() in a useEffect and return the cleanup function it gives you.
Config reference
store, channel, event, idbKey, and ttl are required. Everything else is opt-in per store — a store with none of the optional fields set still gets full IDB caching and realtime sync.ingestionType
COLLECTION_ALL if omitted.LRU stores are read on-demand rather than hydrated at boot — is covered per-type under ingestion/*.cacheStrategy
ingestionType is LRU. Sets the byte budget for the partition — set maxBytes directly rather than maxEntries, which is only a rough backwards-compatible estimate.Whatever you configure, Flux clips the effective budget to 50MB and logs a console warning if clipping occurs — this protects against iOS Safari's aggressive storage eviction once an origin's usage spikes.
scope
'global' — this store's data survives logout and session timeout indefinitely. Set it to 'user' for anything tenant-specific: dashboards, billing, private queues.If a channel or idbKey looks sensitive — matching something like dashboard, billing, or account — but scope is left unset, Flux logs a console warning in development only. It's advisory, never blocking: unscoped means it won't be cleared on logout. See core-concepts/multi-tenant-scoping.
queueConfig — offline writes
queueConfig turns this store's mutations into offline-safe writes: they commit to IndexedDB immediately and replay automatically once the connection returns.replayStrategy, revalidateFn, and how conflicts surface — is covered in core-concepts/offline-queue and core-concepts/conflict-resolution.jobTracker — async job progress
jobTracker interprets realtime row updates on this channel as job status transitions and fires progress/completion callbacks automatically.flux.trackJob() instead. See api/track-job.Callbacks
hydrateState, onStale, and onRealtimeUpdate give you hooks into the three moments data can reach this store — cold boot from IDB, a bootstrap fetch, and a live realtime event.Unregistering and hot reload
register() returns tears down the realtime subscription and any job poller for that channel. In development, re-registering an already-registered channel silently replaces it — safe for HMR. In production, a duplicate registration logs a warning and is skipped rather than silently replacing a live store.For populating every registered store in one network call, see api/bootstrap. For the isolation model behind scope, see core-concepts/multi-tenant-scoping.