Socket.IO
Hand Flux an existing socket.io-client instance and it takes care of turning your own server's events into live store updates — reconnect handling, single-socket coordination across tabs, and catch-up after time offline all come for free once the adapter is wired in.
- An existing backend emitting events over Socket.IO — any language, any framework
- socket.io-client already installed on the frontend
- @tsworldtech/flux and @tsworldtech/flux-socketio installed
Create the adapter
socket.io-client instance yourself, then pass it into createSocketIOAdapter(). Set autoConnect: false when constructing the socket — Flux opens the connection itself once a store actually registers, rather than connecting immediately on page load regardless of whether anything needs it.Register a store
channel and event together form the exact socket event name Flux listens for. Whatever name you register is the name your server emits under for live forward events.The channel:event naming convention
channel and event combine into a single string, `${channel}:${event}`, and that string is exactly what your server emits under for live events.There's nothing to "subscribe" to on the server beyond emitting under the right event name — your backend can broadcast live updates with one plain io.emit() call, and only clients that registered a listener for that exact name react to it.
Protocol Handshakes: Sync and Reconcile
`${channel}:${event}` broadcasts, the Socket.IO adapter executes explicit message handshakes for delta catch-up and deletion reconciliation:What your server needs to send
getting-started/node-socketio, but nothing about the adapter itself is Node-specific.Authentication
Pass an auth token the same way you would with any socket.io-client connection — via the auth option at construction, or updated before a reconnect via socket.auth. Flux never inspects or modifies this; it only calls connect() and disconnect() on the socket instance you give it.
Multiple open tabs
Only one browser tab holds the live connection at a time — if you open the same app in five tabs, your server still only sees one socket for that device. The other tabs stay fully in sync without opening a connection of their own, and if the tab holding the connection closes, another tab takes over automatically.
For the server-side implementation this adapter expects, see getting-started/node-socketio. For what happens during reconnect specifically, see core-concepts/sync-anchors and core-concepts/activity-bus.