Skip to main content

Function: useWebSocket()

function useWebSocket<T>(options: object): void

React hook for WebSocket subscription to Kubernetes resources

Type Parameters

Type ParameterDescription
TType of data expected from the WebSocket

Parameters

ParameterTypeDescription
optionsobjectConfiguration options for the WebSocket connection
options.cluster?stringThe Kubernetes cluster ID to watch
options.enabled?booleanWhether the WebSocket connection should be active
options.onError?(error: Error) => voidCallback function to handle connection errors
options.onMessage(data: T) => voidCallback function to handle incoming messages
options.url() => stringFunction that returns the WebSocket URL to connect to

Returns

void

Defined in

src/lib/k8s/api/v2/webSocket.ts:393