What is SSE
Server-Sent Events (SSE) is a protocol for one-way real-time communication from server to client. The client opens an HTTP connection, and the server sends events as they occur. The connection stays open and the server writes events as text/event-stream — a simple text format with event names, data, and IDs.
How it works
The client calls new EventSource('/events') in the browser. The server responds with Content-Type: text/event-stream and keeps the connection open. Each event is a block of text lines: event: (type), data: (payload), and id: (for resumption). If the connection drops, the browser automatically reconnects and sends the Last-Event-ID header so the server can resume from where it left off.
Why it matters
SSE is simpler than WebSockets for server-to-client push. It's plain HTTP, so it works through proxies, CDNs, and firewalls without special configuration. Automatic reconnection and event ID resumption are built in. The tradeoff: SSE is one-directional (server to client only). If you need the client to send messages too, use WebSockets.
See How WebSockets Work for a comparison of WebSockets, SSE, and polling.