React context provider exposing WebSocket connection status, state, and reconnect logic for use in data‑fetching hooks.
// Source: https://github.com/BradGroux/veritas-kanban | License: MIT | Copyright 2026 Digital Meld
// Provided via justclaw.it.com; keep this notice with the code.
import { createContext, useContext, useMemo, type ReactNode } from 'react';
import type { ConnectionState } from '@/hooks/useWebSocket';
interface WebSocketStatus {
/** Whether the WebSocket is currently connected */
isConnected: boolean;
/** Detailed connection state */
connectionState: ConnectionState;
/** Current reconnect attempt (0 when connected or idle) */
reconnectAttempt: number;
/** Manually retry the WebSocket connection after a disconnected state */
reconnect?: () => void;
}
const WebSocketStatusContext = createContext<WebSocketStatus>({
isConnected: false,
connectionState: 'disconnected',
re
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key