createFlux()
The single entry point. Give it an adapter and it hands back the engine object every other part of your app — store registrations, bootstrap calls, queue replays, session teardown — talks to for the lifetime of the page.
- An adapter created via one of the adapters/* packages
- @tsworldtech/flux installed
Basic usage
createFlux() once, at module scope, outside any component. The returned object is what you pass to FluxProvider and what every flux.register() call in your app runs against.Create flux exactly once and import it wherever you need it — don't call createFlux() inside a component body. A second instance means a second IDB connection, a second realtime leader election, and a second offline queue running in parallel with the first.
Config reference
adapter is required. Everything else has a sensible default and can be added later without touching anything else in your app.storagePrefix
onConflictUnified
replayStrategy: 'handshake' produces or resolves a write conflict on reconnect. Always called with the complete current list, not just what changed — this is the one callback a universal conflict-resolution UI needs.core-concepts/conflict-resolution for how conflicts are produced, and api/resolve-unified-conflict for acting on them.onStorageFallback
What you get back
FluxEngine is the full public surface of Flux. Most of these have their own dedicated reference page — this is the map.Inside components, prefer useFlux() over reading properties off flux directly — it re-renders your component when isHydrated, isBootstrapped, currentUserId, or activeConflicts change. Reading flux.isHydrated directly in a render body will not trigger a re-render when it flips.
Sessions and multi-tenant data
currentUserId and clearUserSession() exist on every tier, not just Pro — call clearUserSession() from your logout handler so any store registered with scope: 'user' is purged from IndexedDB, the offline queue, and every other open tab.core-concepts/multi-tenant-scoping.flux, the next step for most apps is registering your first store and firing a single bootstrap call — see api/register and api/bootstrap.For per-store configuration, see api/register. For the single-network-call boot sequence, see api/bootstrap. For licensing, see license/setup.