Sends raw coordinates
Backend & Runtime / Knowledge library
Server-Sent Events (SSE)
Streams one-way text events from an HTTP server to a browser
Why learn Server-Sent Events (SSE)?
It offers automatic reconnection for simple server push
The problem it solves
It updates clients continuously without bidirectional WebSocket complexity
Where it came from
Server-Sent Events (SSE) is a networking and web concept that streams one-way text events from an HTTP server to a browser. Its guarantees and tradeoffs depend on the concrete implementation and operating context.
Build your understanding
Work through these exercises in order. Try the task before opening a reference.
- Define Server-Sent Events (SSE) and distinguish it from a neighboring concept.
- Choose a realistic task where Server-Sent Events (SSE) is appropriate.
- Identify a failure mode caused by misusing Server-Sent Events (SSE).
- Interpret a small design or result involving Server-Sent Events (SSE).
- Explain one tradeoff or limitation of Server-Sent Events (SSE).
Documentation and sources
- MDN Web Technology Glossary (developer.mozilla.org)
Connect the ideas
Explore next
Real World Example
Real-time Logistics Fleet Tracking
A regional logistics company managing a fleet of delivery vehicles that require constant location updates for dispatchers.
The business problem
Dispatchers rely on manual page refreshes to see vehicle positions, leading to stale data and inefficient routing decisions during peak traffic hours.
How this topic solves it
Server-Sent Events (SSE) enables a persistent, unidirectional HTTP connection from the server to the dispatcher dashboard, pushing location updates immediately as they arrive from GPS sensors without requiring client-side polling.
- Configure the server to set the Content-Type header to text/event-stream.
- Maintain an open HTTP connection between the client EventSource object and the server.
- Format outgoing data messages with the data: prefix followed by the JSON payload.
- Implement client-side event listeners to handle incoming location updates and update the UI dynamically.
The flow shows how GPS data moves from the vehicle to the dispatcher dashboard.
Processes and streams data
Receives updates via EventSource
- GPS Sensor → HTTP POST → Backend Server
- Backend Server → text/event-stream → Dispatcher Dashboard
Expected business outcome
Dispatchers gain a fluid, real-time view of fleet operations, allowing for proactive adjustments to delivery routes and improved response times to traffic incidents.
Limitations and checks
SSE is strictly unidirectional, meaning the client cannot send data back to the server over the same connection; developers must check the browser console for connection closure events to trigger manual reconnection logic.