Realtime browser events

For server-to-client updates, start with SSE.

SSE uses regular HTTP and native EventSource reconnects. WebSocket fits infrastructure built around upgraded connections. In MsgMesh both are downstream-only; publishing uses HTTP.

Quick choice

SSE is simpler. WebSocket may fit an existing network stack.

DimensionSSEWebSocket
DirectionServer → clientMsgMesh is server → client only; upstream frames are discarded
Native browser reconnectBuilt into EventSourceNo; the official SDK handles it
Resume cursorLast-Event-ID or the from parameterResume mode with the from parameter
Node.jsThe JavaScript SDK stream() currently supports browsers onlyBrowser or Node 22+
Best forNotifications, dashboards, job progress, and common live viewsNetworks that block SSE or teams already operating WebSockets

History and resume

Load history, then join live delivery at the same cursor.

Read recent history

The history API returns events and resume_from. It is the handoff to a live connection, not a next-page cursor.

Open the live stream with the cursor

SSE uses Last-Event-ID or from; WebSocket resume mode also uses from. The official SDK stores and returns the cursor.

Deduplicate boundary overlap

At-least-once allows small overlaps. Official SDKs deduplicate by partition cursor; native API users must do this themselves.

Rebuild when catch-up is incomplete

Past retention or the 5,000-message replay limit, msgmesh-resync tells the app to rebuild a snapshot from its own system.

Browser security

Never put a long-lived API key in the frontend.

01

Keep long-lived keys on the backend

Browser code and requests are inspectable. Long-lived keys do not belong in bundles, HTML, or localStorage.

02

Issue a short-lived, reduced token

Use your token-broker to issue a token for at most 15 minutes, limited by action, topic, and room.

03

Let the SDK renew it

With a token callback, the SDK refreshes before expiry and uses the new token after reconnecting.

Keep reading

Compare both connections in the public demo.

No registration. Switch protocols, send one event, and observe the difference.

Switch between SSE and WebSocket →