Skip to content

Realtime with SSE

Most pages are fine with request/response: your POST patches your view. Opt into SSE only when a page must reflect changes it didn’t initiate.

Add a pragma to a .stator route’s frontmatter (or live: true on a .ts route’s defineRoute):

---
// @stator live
---

Stator injects a live marker; the client opens one EventSource for the route. No client code required.

When any session changes a machine the route reads, the server recomputes the affected bindings and pushes the patches to every open connection on that route — not just the originating session. The patch shape is identical to a POST response; only the transport differs.

  • Opt-in — a route is static request/response until // @stator live.
  • Reconnect = reload — a dropped connection re-renders; there’s no missed-event replay.
  • Single-replica — fan-out is in-process.