🌐Server-Sent Events (SSE)
Also known as SSE, EventSource, Event Stream
A server sends updates to the browser. They go one way, over plain HTTP.
Think of it like
Think of it like a radio. The station keeps sending, and you just listen.
Example
Lucy's order page listens with SSE. When the parcel ships, the server sends one line, and the status changes on screen.
Why it matters
Definition
Example code
javascript
const source = new EventSource("/updates");
source.onmessage = (event) => console.log(event.data);Common mistake
Key takeaways
- 1One way. Server to browser only.
- 2Plain HTTP. Works through most networks.
- 3Reconnects itself. EventSource retries for you.