Skip to content
Prompt Words
History

Server-sent events (SSE)

Also called: SSE, EventSource, event stream, server push.

The page opens one connection that stays open, and the server pushes a message down it each time something happens. It only goes one way, from the server to the page, and the browser reconnects by itself if the connection drops.

The page opens one stream and keeps it open. The server pushes each message down it the moment it happens. Drop the connection: the browser reconnects and asks for what it missed.

Closed

Say it in a prompt

Push order status changes with server-sent events: GET /api/orders/:id/events answers with Content-Type text/event-stream, sends each change as an "event: status" message with an id, and sends a ": ping" comment every 15 s. In the browser use EventSource, update the status badge on each event, and let it reconnect with Last-Event-ID so no change is missed.

Seen on

  • Claude API: With "stream": true, the reply arrives as server-sent events such as message_start, content_block_delta and message_stop.
  • MDN Web Docs: The EventSource guide: the server answers with text/event-stream, the connection only goes one way, and the browser reconnects after the retry time.

You might describe it as

  • the server pushes new messages to the page without being asked
  • AI chat answer that streams in piece by piece
  • live feed that updates the moment something happens

Not to be confused with

  • Polling

    Server-sent events keep one connection open and the server pushes; polling sends a new request every few seconds to ask.

  • WebSocket

    Server-sent events only go from the server to the page, over plain HTTP; a WebSocket carries messages both ways.

  • Streaming results

    Server-sent events push messages from the server to a page over one open connection; streaming results means a program reads big data in small pieces so its memory stays small.