Why it matters

SSE is underused. Many apps default to WebSockets for one-way scenarios where SSE would be simpler. Understanding the trade-off matters.

Advertisement

The architecture

Client: new EventSource(url). Sends GET; server responds with text/event-stream.

Server: writes event: name\ndata: content\n\n frames. Client fires events on receive.

SSE mechanismClient EventSourceHTTP GETServer streamstext/event-streamEvents + auto-reconnectbuilt into browserNative browser API handles reconnection with Last-Event-ID; simpler than WebSocket
SSE flow.
Advertisement

How it works end to end

Auto-reconnect: EventSource reconnects on disconnect. Last-Event-ID header lets server resume from disconnect point.

Simpler than WebSocket: standard HTTP, works through most infrastructure, no upgrade handshake.

One-way only: client-to-server needs a separate mechanism (regular HTTP POST).

LLM streaming often uses SSE.