SSE
Point Flux at any endpoint that speaks standard Server-Sent Events and it takes care of turning that stream into live store updates — reconnect handling, single-connection coordination across tabs, automatic backfill via URL parameters, and optional POST reconciliation all come for free once the adapter is wired in.
- A backend serving Server-Sent Events on a per-channel URL — any language or framework
- @tsworldtech/flux and @tsworldtech/flux-sse installed
Create the adapter
createSseAdapter() accepts a config object with a url function and an optional reconcileUrl function. The adapter opens connections lazily, one per channel, only once a store actually registers.Register a store
channel determines which URL gets opened; event is the named SSE event your backend dispatches under on that stream — commonly 'UPDATE', matching the event name on your backend's event: UPDATE\ndata: ...\n\n frames.One connection per channel with URL sync anchors
?syncAnchor=<unixMs> (defaulting to 0). Your backend reads this parameter to stream backfill deltas before transitioning to live broadcasts.Deletion reconciliation (POST)
reconcileUrl is configured:Reconnects and catch-up are automatic
You never need to write reconnect logic yourself. If a connection drops — network blip, tab backgrounded, server restart — Flux reopens it automatically with backoff. The adapter always appends ?syncAnchor=<unixMs> to the channel URL using the highest processed event timestamp, allowing your server to execute a targeted changelog query and stream backfill events down the new connection.
Any backend that speaks SSE
Anything that can hold an HTTP connection open and write text/event-stream frames works here — Node, Python, Go, Rails, PHP, whatever you already run. Flux only ever talks to a plain URL over standard SSE; there's no required backend framework or language.
Authentication
The browser's native EventSource can't attach custom headers, so a bearer token in an Authorization header isn't an option. The common patterns are a short-lived signed token appended to the channel URL as a query parameter, or same-origin cookies if your app and API share a domain.
Building the server side of this contract from scratch? See getting-started/node-sse for a full worked example. For what happens during reconnect specifically, see core-concepts/sync-anchors and core-concepts/activity-bus.