Push live updates with Server-Sent Events

Server-Sent Events keep a single HTTP connection open, so the server can push updates whenever it wants. In Jeasx a route simply returns a standard Response wrapping a ReadableStream.

The values below are pushed by the server every second and rendered by a few lines of vanilla JavaScript using EventSource. Disconnect to see the stream being cancelled on the server: its timer is cleaned up and the client counter goes down in all other open windows.

Server stats

Connecting…
Server time
–
Uptime
–
Heap used
–
Clients on this server
–