Server-Sent Events (SSE) technology allows the server to continuously send data to the browser without the client having to make repeated requests.
SSE (Server-Sent Events) is a one-way communication channel in which the server sends events to the browser via HTTP. Itβs particularly useful for displaying live data such as weather updates, stock prices, or notifications.
In the browser, the 'EventSource' object is used to receive events. The 'onmessage' event handler is triggered each time the server sends a new message.
The server must respond with the 'text/event-stream' content type and continuously send data in the correct SSE format. In a Node.js example, the current date is sent every second.
- Simpler than WebSocket in many cases - Automatic reconnection if the connection drops - Great for read-only data (e.g., dashboards, alerts)
SSE only supports one-way communication (server β client), may be unreliable behind some proxies, and is sensitive to mobile networks. For high-load or bidirectional applications, WebSocket or another technology is recommended.
β¨ Ask Lara β your AI study partner
Unlock personalized learning support. Lara can explain lessons, summarize topics, and answer your study questions β available from the Go plan and above.
Lara helps you learn faster β exclusive to ReadyTools Go, Plus, and Max members.