How it works
The browser opens a connection with the EventSource API, and the server keeps the response open, writing short text messages (content type text/event-stream) whenever something happens. If the connection drops, the browser reconnects on its own and can tell the server the last event it received. Data flows one way only; the browser still sends anything of its own with normal requests.
Because it is plain HTTP, SSE passes through most proxies, CDNs and load balancers and needs no special server. The OpenAI, Anthropic and Gemini APIs stream model output this way. Over HTTP/1.1 a browser allows only about six open connections per site across all tabs, a limit HTTP/2 removes, and messages are text only.
Server-Sent Events (SSE) pros and cons
Pros
- Simpler than WebSockets for one-way updates
- Automatic reconnection built into the browser
- Plain HTTP, so it works with most hosts and proxies
Cons
- Server to client only, with no messages from the browser
- Text only, and HTTP/1.1 limits open connections per site
When to use Server-Sent Events (SSE)
Pick it when
- Streaming AI responses, logs or progress to a browser
- Live scores, feeds and notifications
Skip it when
- The client also needs to send frequent messages (use WebSockets)
Server-Sent Events (SSE) pricing
Server-Sent Events (SSE) vs the alternatives
Related terms
More in Backend and APIs
Realtime