# Server-Sent Events (SSE)

> A server sends updates to the browser. They go one way, over plain HTTP.

**Field:** Software Development  
**Category:** Web Development  
**Also known as:** SSE, EventSource, Event Stream

## Think of it like

Think of it like a radio. The station keeps sending, and you just listen.

## Definition

Server-sent events let a server push updates to the browser. They flow over one web request that stays open. Unlike a WebSocket, messages go only one way, from server to browser. The browser listens with a built-in tool called EventSource, which reconnects on its own. Each message is plain text that starts with data:. It suits live scores, progress bars and AI answers that stream in.

## Example

Lucy's order page listens with SSE. When the parcel ships, the server sends one line, and the status changes on screen.

## Example code

```javascript
const source = new EventSource("/updates");
source.onmessage = (event) => console.log(event.data);
```

Listen for each update the server sends to /updates.

## Why it matters

When only the server needs to talk, SSE is simpler than a WebSocket. It also reconnects for free.

## Common mistake

Using it when the browser must also send often. Then a WebSocket is the better fit.

## Three principles

- **One way.** Server to browser only.
- **Plain HTTP.** Works through most networks.
- **Reconnects itself.** EventSource retries for you.

## Related terms

- [WebSocket](https://learn.benibix.com/term/development/websocket)
- [Polling](https://learn.benibix.com/term/development/polling)
- [Back End](https://learn.benibix.com/term/development/back-end)
- [Browser Event](https://learn.benibix.com/term/development/browser-event)
- [HTTP+SSE Transport](https://learn.benibix.com/term/ai/http-sse-transport)

## Told apart from

- [WebSocket vs Server-Sent Events](https://learn.benibix.com/compare/websocket-vs-server-sent-events): Both keep a line open so news arrives at once. A WebSocket lets both sides send. Server-sent events only flow from the server to the browser.

---

Source: https://learn.benibix.com/term/development/server-sent-events
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
