Skip to main content

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.

This hook requires the OrderbookProvider to be present in your component tree.

Import

import { useOrderbookStatus } from '@krono/hooks'

Usage

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:
status
'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

Examples

Blocking UI during Connection

Use the status to prevent user interaction while the orderbook is initializing.
function TradingButton() {
  const status = useOrderbookStatus();
  const ready = status === 'connected';

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

Orderbook Core

Explore the underlying class logic and event emitters.

useOrderbookData

Access the live snapshot of the current orderbook.

useOrderbookHistory

Access historical orderbook data.

Kraken API

Explore the book channel streams level 2 order book docs.