100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Web

Server-Sent Events

IntermediateProtocol5.9K learners

Server-Sent Events (SSE) is a web standard that lets a server push a continuous stream of text-based updates to a client over a single, long-lived HTTP connection, using a simple event-stream format the browser parses natively.

Definition

Server-Sent Events (SSE) is a web standard that lets a server push a continuous stream of text-based updates to a client over a single, long-lived HTTP connection, using a simple event-stream format the browser parses natively.

Overview

SSE solves a narrower version of the problem WebSockets solve: when a client only needs to receive updates from the server — not send them back over the same channel — SSE offers a much simpler mechanism built directly on HTTP. A client opens a connection to an endpoint using the browser's `EventSource` API, and the server keeps that connection open, writing a stream of `data:`-prefixed text events that the browser automatically parses and delivers as JavaScript events, complete with built-in reconnection if the connection drops. Because SSE is just HTTP, it works transparently with existing infrastructure — proxies, load balancers, and CDNs that understand HTTP generally don't need special configuration the way WebSocket upgrades sometimes do, and requests can be authenticated with normal HTTP headers or cookies. This makes SSE a popular choice for use cases like streaming AI model output token-by-token, live news or score updates, progress bars for long-running jobs, and notification feeds — anywhere data flows mostly in one direction, from server to client. The tradeoff is that SSE is one-way and text-only by default (binary data must be encoded), and browsers cap the number of concurrent SSE connections per domain over HTTP/1.1, though HTTP/2 multiplexing largely removes that limit. When an application genuinely needs the client to push data back over the same low-latency channel, WebSockets remain the better fit. It is often mentioned alongside REST API in this space.

Specification

  • One-way streaming from server to client over plain HTTP
  • Native browser support via the EventSource API
  • Built-in automatic reconnection on dropped connections
  • Works transparently with most existing HTTP infrastructure
  • Simple text-based event-stream format
  • No special protocol upgrade or handshake required

Use Cases

Streaming AI chat responses token-by-token
Live sports scores and news tickers
Progress updates for long-running background jobs
Real-time notification feeds
Dashboard metrics that update continuously
Log streaming from a server to a browser console

History

Server-Sent Events (SSE) is a browser standard for one-way, server-to-client streaming over a single long-lived HTTP connection, consumed through the JavaScript EventSource API. Unlike WebSockets, SSE is unidirectional and text-based, automatically reconnects, and supports event IDs and named event types — a good fit for live feeds such as notifications, stock tickers, and streaming AI responses. The technique was first implemented experimentally in the Opera browser in 2006 under the name "Server-Sent Events." After years of iteration it was published by the W3C as a Recommendation on February 3, 2015, and it is now maintained as part of the WHATWG HTML Living Standard.

Frequently Asked Questions

From the Blog