API Reference
useFlux()
A single hook exposing the engine's live status — connectivity, queue depth, hydration, bootstrap state, unresolved conflicts, and the active user — so components can react to Flux without reaching into the engine instance directly.
Prerequisites
- FluxProvider mounted above this component — see api/with-flux
- @tsworldtech/flux-next or @tsworldtech/flux-react installed
1
Basic usage
Import
useFlux from whichever framework package you're using — the returned shape is identical, since this hook has no Next.js-specific behavior of its own.typescript
2
Return shape
Six fields, each mirroring a corresponding piece of state on the engine itself.
typescript
3
isOnline and queueCount
Use these together to drive an offline banner or a "pending sync" indicator without wiring your own
online/offline listeners or reading the queue yourself.typescript
4
hydrated and isBootstrapped
hydrated mirrors flux.isHydrated, isBootstrapped mirrors flux.isBootstrapped — the same two flags HydrationGate gates on, exposed here for any component that wants to check them directly instead of wrapping in the gate.typescript
5
activeConflicts
The live array from
flux.getActiveConflicts(), kept updated internally via the same subscription mechanism as subscribeToConflicts(). Read this to conditionally render a conflict resolution panel.typescript
6
currentUserId
Mirrors
flux.currentUserId, letting a component react to session start/end — set by a 'user'-scope bootstrap() call, cleared by clearUserSession() — without wiring its own auth listener.typescript
7
Composing multiple fields
Most real usage reads several fields from one call rather than sprinkling separate hooks — a top bar showing connectivity, pending syncs, conflicts, and auth state all from a single
useFlux().typescript
For corrected timestamps instead of engine status, see the separate api/use-flux-time hook. For resolving what activeConflicts surfaces, see api/resolve-unified-conflict.