websocket-patterns

Manage WebSocket connections with backoff, heartbeats, and DuckDB event routing.

1|Updated Apr 17, 2026
One-click install
npx skills add https://github.com/PremModhaOfficial/motadata-ai-pipeline --skill websocket-patterns-premmodhaofficial
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: websocket-patterns
Source: https://github.com/PremModhaOfficial/motadata-ai-pipeline/tree/main/.claude/skills/websocket-patterns
Command: npx skills add https://github.com/PremModhaOfficial/motadata-ai-pipeline --skill websocket-patterns-premmodhaofficial

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provide robust real-time WebSocket support for frontend components, including connection lifecycle, token handling, exponential backoff, heartbeat pings, offline queueing, and a SyncManager bridge to DuckDB for live data.

Core Features & Use Cases

  • Connection lifecycle management: establish, monitor, and gracefully tear down WebSocket connections with proper state.
  • Exponential backoff reconnection: resilient auto-reconnect with jitter to reduce server pressure.
  • Auth token handling: inject tokens securely and refresh as needed without exposing credentials.
  • Event routing & message format: standard event envelope and routing to DuckDB-backed views.
  • Offline support & visibility awareness: queue events when offline or tab hidden and flush on visibility restoration.
  • SyncManager bridge to DuckDB: enable real-time updates to DUCKDB tables used by frontend listing pages.

Quick Start

Configure the WebSocketManager with a secure URL and a token retriever to establish a connected real-time channel for your listing pages.

Frequently Asked Questions about websocket-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle WebSocket reconnection with exponential backoff in a frontend application?▼

WebSocket reconnection with exponential backoff is handled automatically using jitter to reduce server pressure. The connection lifecycle monitors state and gracefully tears down or re-establishes sockets without manual intervention.

How do I route real-time WebSocket events to DuckDB-backed frontend dashboards?▼

Real-time WebSocket events are routed to DuckDB-backed views using a SyncManager bridge. This updates frontend listing pages directly by syncing the standard event envelope into DuckDB tables.

How can I securely inject auth tokens into a WebSocket connection lifecycle?▼

Auth tokens are injected securely into the WebSocket connection lifecycle via a token retriever. This handles token refreshes as needed during the connection without exposing credentials in the frontend.

How do I queue WebSocket events when the browser tab is hidden or offline?▼

WebSocket events are queued automatically when the browser tab is hidden or the connection is offline. The offline queue flushes events upon visibility restoration to ensure no real-time data is lost.

What is the best way to maintain heartbeat pings for a real-time WebSocket UI?▼

Heartbeat pings for a real-time WebSocket UI are maintained through continuous connection lifecycle monitoring. This ensures the live socket remains active and handles graceful teardown when the connection drops.