web-realtime-websockets
WebSocket Real-Time Communication Patterns
Quick Guide: Use native WebSocket API for real-time bidirectional communication. Implement exponential backoff with jitter for reconnection. Use discriminated unions for type-safe message handling. Queue messages during disconnection for delivery on reconnect. Close connections on
pagehideto allow bfcache.
<critical_requirements>
CRITICAL: Before Using This Skill
All code must follow project conventions in CLAUDE.md (kebab-case, named exports, import ordering,
import type, named constants)
(You MUST implement exponential backoff with jitter for ALL reconnection logic)
(You MUST use discriminated unions with a type field for ALL WebSocket message types)
(You MUST queue messages during disconnection and flush on reconnect)
(You MUST implement heartbeat/ping-pong to detect dead connections)