TypologySienna Chen
InputLightweight

Realtime stream (WebSocket)

Data pushed the moment it happens.

Data pushed from a server the moment it happens: sensors, prices, other people’s actions. The page updates without asking. Needs a server and a plan for when the connection drops.

Breaks when
needs a server; static hosting will not do
Also called
WebSocket, SSE, WebRTC, PartyKit

Prompts

Live chart that never jumps
A PartyKit server that broadcasts a value every 100–600 ms (simulated sensor) to all clients. The client keeps a ring buffer of 600 frames, draws a Canvas 2D line with time on x (so irregular arrivals plot correctly), interpolates the newest point toward its target, shows connection state (connecting / open / reconnecting) and reconnects with exponential backoff. Batch DOM updates; do not re-render on every frame if two arrive in one rAF.
SSE for one-way data
Replace the WebSocket with Server-Sent Events for a read-only feed: an endpoint that streams text/event-stream, an EventSource client with automatic reconnect and Last-Event-ID, and the same chart. Explain when SSE is enough and when WebSockets are needed.
Backpressure
Handle a stream faster than the display: coalesce frames per animation frame, keep only the latest value for gauges and all values for the chart buffer, and show a dropped-frames counter. Provide a slow-network mode that throttles the server to test it.

Related

Resources · 2

  • Liveblocksliveblockssite · demoJul 12, 2026
  • PartyKitpartykit_iosite · code · demoMay 20, 2026