> ## Documentation Index
> Fetch the complete documentation index at: https://krono.fabianpiper.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# useOrderbookStatus

> Hook for accessing the orderbook websocket connectivity state.


<Note>
  This hook requires the `OrderbookProvider` to be present in your component tree.
</Note>

## Import

```ts theme={null}
import { useOrderbookStatus } from '@krono/hooks'
```

## Usage

```tsx theme={null}
import { useOrderbookStatus } from '@krono/hooks'

function ConnectionStatusBadge() {
  const status = useOrderbookStatus();

  return (
    <div className={`badge badge-${status}`}>
      Status: {status}
    </div>
  );
}
```

***

## Return Type

Returns a `ConnectionStatus` string literal:

<ResponseField name="status" type="'disconnected' | 'connecting' | 'connected' | 'error'">
  * `disconnected`: The socket is idle or manually closed
  * `connecting`: A connection or subscription is in progress
  * `reconnecting`: Reconnect after connection closed
  * `connected`: The socket is open and actively receiving heartbeat/data
  * `error`: The connection failed or encountered an error
</ResponseField>

## Examples

### Blocking UI during Connection

Use the status to prevent user interaction while the orderbook is initializing.

```tsx theme={null}
function TradingButton() {
  const status = useOrderbookStatus();
  const ready = status === 'connected';

  return (
    <button disabled={!ready}>
      {ready ? 'Place Order' : 'Waiting for connection...'}
    </button>
  );
}
```

***

## Related

<CardGroup cols={2}>
  <Card title="Orderbook Core" icon="toy-brick" href="/docs/core/api/classes/Orderbook">
    Explore the underlying class logic and event emitters.
  </Card>

  <Card title="useOrderbookData" icon="chevrons-left-right-ellipsis" href="/docs/hooks/api/useOrderbookData">
    Access the live snapshot of the current orderbook.
  </Card>

  <Card title="useOrderbookHistory" icon="history" href="/docs/hooks/api/useOrderbookHistory">
    Access historical orderbook data.
  </Card>

  <Card title="Kraken API" icon="link" href="https://docs.kraken.com/api/docs/websocket-v2/book">
    Explore the `book` channel streams level 2 order book docs.
  </Card>
</CardGroup>
