← Blog

How we build chat with Server-Sent Events

When SSE beats WebSockets for chat, and how we wire it up in Nuxt.

·
backendnetworking #chat #sse #realtime

We default to Server-Sent Events for one-directional realtime — chat streams, notifications, live status — and reserve WebSockets for genuinely bidirectional, low-latency cases.

Why SSE first

SSE rides plain HTTP: no protocol upgrade, works through most proxies, and reconnects automatically with Last-Event-ID. For chat, the read path is the hard part, and SSE handles it with far less moving infrastructure.

The shape

A Nitro route streams text/event-stream; the client consumes it with EventSource. Outbound messages go over a normal POST. That asymmetry — read over SSE, write over HTTP — keeps the whole thing debuggable with curl.

Koala42 — internal developer wiki