Server-Sent Events

A standard way for a server to keep an HTTP response open and push a stream of text events to the client, in one direction only.

In more detail

Each event is a few text fields, such as id, event and data, ended by a blank line, sent as text/event-stream. Browsers reconnect automatically and send the last event identifier so the server can resume. Use a WebSocket instead when the client must also send messages continuously.

Examples

In the browser: The browser's EventSource object reconnects automatically and delivers each event to your code.
id: 5
event: tick
data: {"val":42}

data: {"token":"Hello"}

Related terms

Taught in

References

Certification courses