Skip to content

Server-Sent Events Pattern

Medium — good to knowNetworking

ELI5 — The Vibe Check

Server-Sent Events (SSE) is a one-way stream from server to browser over plain HTTP. The server pushes updates, the client just listens. No WebSocket complexity, automatic reconnection built in, works through proxies. Perfect for notifications, live feeds, and dashboards where the client just needs to receive.

Real Talk

Server-Sent Events is an HTTP-based protocol for server-to-client streaming using the EventSource API. It uses text/event-stream content type, supports automatic reconnection, event IDs for resumption, and named event types. Simpler than WebSockets for unidirectional use cases.

Show Me The Code

// Client
const source = new EventSource('/api/events');
source.onmessage = (e) => console.log(e.data);
source.addEventListener('notification', (e) => {
  showNotification(JSON.parse(e.data));
});

When You'll Hear This

"SSE powers our real-time dashboard — the server pushes metric updates every second." / "SSE auto-reconnects when the connection drops — one less thing to implement."

Made with passive-aggressive love by manoga.digital. Powered by Claude.