Skip to main content
This hook requires the OrderbookProvider to be present in your component tree to provide the underlying Orderbook instance.

Import

Usage


Parameters

This hook does not accept any parameters. It automatically interfaces with the Orderbook instance provided by the nearest context provider.

Return Type

State

'connecting' | 'open' | 'closing' | 'closed'
The current state of the WebSocket connection.

Actions

() => void
Initiates a connection to the exchange WebSocket. If a connection is already in progress or open, this method usually performs no action.
() => void
Gracefully closes the active WebSocket connection and stops data processing.

Examples

Connection

Ensure a connection is active when a component mounts.

Reconnection Status UI

Because status is reactive, you can use it to drive complex UI states like loading spinners or error banners.

Orderbook Core

Explore the underlying class logic and connection event emitters.

useOrderbookStatus

The internal hook used to track refined connection states.

useOrderbookConfig

Change symbols or depth before calling the connect method.

Kraken API

Explore the book channel streams level 2 order book docs.