Match Transport Capabilities to Data Direction
Telemetry charts, deployment logs, and LLM token streams only flow from server to browser. Server-Sent Events (SSE) operate over standard HTTP with built-in automatic reconnection and far simpler load-balancer behavior.
Reserve WebSockets for genuinely bidirectional collaborative canvases, multiplayer cursors, or sub-50ms interactive editing.
tslib/sse-client.ts
export function subscribeTelemetry(url: string, onEvent: (data: unknown) => void) {
const source = new EventSource(url);
source.onmessage = (event) => onEvent(JSON.parse(event.data));
return () => source.close();
}