Overview
Thekraken-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
- 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: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.