web-realtime-sse
Installation
SKILL.md
Server-Sent Events (SSE) Patterns
Quick Guide: SSE pushes text from server to client over an ordinary HTTP response, so it crosses proxies and firewalls that block anything more exotic.
EventSourcegives reconnection andLast-Event-IDreplay for free but is GET-only and cannot set headers; fetch streaming gives up both and buys custom headers, POST bodies and anAbortController. The facts that change the answer:EventSourceretries network errors but gives up permanently on an HTTP error status,retry:is milliseconds, andConnection: keep-aliveis prohibited on HTTP/2+.
Detailed Resources:
- examples/core.md — EventSource lifecycle, named events, credentials, a state-tracking wrapper, typed messages, and the React hooks built on them
- examples/fetch-streaming.md — stream reader with buffer handling, field parser, auth headers, POST streaming, token-by-token UI
- examples/reconnection.md —
Last-Event-IDrecovery, exponential backoff, health checks, visibility-aware pausing - reference.md — message format, field behaviour, readyState values, required response headers, EventSource behaviour table
Which path applies
EventSource— the browser reconnects, replays throughLast-Event-IDand parses the wire format for you. It sends GET only, sets no headers, and authenticates by cookie (withCredentials: true). Start at examples/core.md.- Fetch streaming — reach for it when the stream needs an
Authorizationheader, a POST body, or cancellation you control. You then own reconnection, backoff,Last-Event-IDand the field parsing. See examples/fetch-streaming.md.
Both consume the same wire format, so the parser and the message types are shared between them.