Skip to main content

Overview

The kraken-book crate compiles to WebAssembly. The same orderbook logic powering Rust backends runs in browser tabs. WASM handles:
  • Orderbook state management
  • Delta application
  • CRC32 checksum validation
  • Spread/mid-price calculations
JavaScript handles:
  • WebSocket connection
  • DOM updates
  • User interaction

Setup

1

Build WASM

2

Copy to project

3

Configure bundler

For Vite:

Basic Usage

React Integration

Message Queue Pattern

Prevent WASM borrow conflicts with sequential processing:
Don’t call WASM functions from multiple async contexts simultaneously.

Symbol Precision

Tips

Limit Depth

Request only what you need. 10-25 levels is enough for most UIs.

Batch Updates

Use requestAnimationFrame for DOM updates, not every message.

Reuse Instances

One WasmOrderbook per symbol. Don’t recreate on each message.

Cleanup

Call book.free() when unmounting to release WASM memory.