realtime-handbook
Installation
SKILL.md
Instructions
Choose and sketch real-time delivery in Next.js (App Router Route Handlers or a dedicated Node service). Read realtime-transports.md before picking SSE vs WebSocket.
When to Use
- Use when notifications, live logs, progress, chat, or collaborative edits need a push channel.
- Prefer polling /
revalidatefirst if latency tolerance is seconds, not milliseconds. - Prefer
auth-handbookfor session or short-lived ticket minting. - Prefer
api-handbookfor upgrade failure error shapes.
- SSE: one-way server → browser; good for notifications, live logs, progress. CORS if cross-origin; reconnection with
Last-Event-IDwhen you implement resume. - WebSockets: full-duplex; chat, collaborative editing. Prefer a short-lived ticket minted server-side when cookie attachment on handshake is unreliable.
- Where it runs: default Node for long-lived connections; Edge is often wrong for fan-out - justify runtime per deployment.
- Scale: sticky sessions or shared pub/sub for multi-instance; document single-node limits.
- Backpressure: slow clients must not block the server - bounded queues, drop or disconnect policy.
- Abuse: rate-limit connects and messages on user-facing endpoints.