Skip to content

SSE, simply

The browser asks once. The server keeps sending updates.

That is Server-Sent Events (SSE). It uses an ordinary HTTP response that stays open, rather than a new request for every update.

Start with a live clock

uv run demo/server.py

Open http://127.0.0.1:8765. The time changes because the server sends a new value every second. The page does not refresh.

Three things to remember

  1. A stream: an HTTP response that stays open for updates.
  2. An event: one text update, finished by a blank line.
  3. EventSource: the browser's built-in JavaScript API for receiving those updates.

For example, the server sends:

event: tick
data: {"time": "2026-11-13T10:30:00+00:00"}

tick names the update. data holds its contents. JSON is a convenient choice, not a requirement of SSE.

A short learning path

  1. Run the demo and watch one clock.
  2. Understand the idea with a tiny browser example.
  3. Try three experiments: inspect, disconnect, reconnect.

You can stop there. You do not need stocks, chat, brokers, or deployment configuration to understand the basic idea.

When you need more

Reconnect is not replay

EventSource normally retries a lost connection automatically. Recovering missed events requires the server to store and replay them. This demo sends live updates only.