WASM Entrypoint
Most users should consume @kalamdb/client high-level APIs. This page covers advanced WASM access.
Warning: this page documents the low-level generated WASM bindings, not the normal
@kalamdb/clientpackage API. If you want the supported high-level client, usecreateClient(...)from@kalamdb/clientand follow the package docs instead of constructingKalamClientfrom@kalamdb/client/wasmdirectly.
Recommended high-level docs:
/docs/ts-sdk/setup/docs/ts-sdk/subscriptions/docs/ts-sdk/client-lifecycle
Import low-level bindings
import init, { KalamClient, WasmTimestampFormatter, parseIso8601, timestampNow, initSync,} from '@kalamdb/client/wasm';Initialization patterns
// async initawait init(); // or explicit module/pathawait init({ module_or_path: '/wasm/kalam_client_bg.wasm' });initSync(...) is available for explicit bytes/module workflows.
Using KalamClient directly
Use this only when you intentionally need the raw WASM interface.
const client = KalamClient.withJwt('http://localhost:2900', '<jwt-token>');await client.connect(); const out = await client.query('SELECT 1');console.log(out);You can also create an anonymous low-level client and supply auth dynamically:
const client = KalamClient.anonymous('http://localhost:2900');client.setAuthProvider(async () => ({ jwt: { token: await getJwt() } }));await client.connect();When using raw WASM methods, some callbacks/events may come as JSON strings requiring manual parse.
Packaging notes
From SDK package metadata:
- package exports include
./wasm - build copies WASM artifacts into
dist/wasmanddist/.wasm-out
Repository builds target a size-first WASM pipeline:
wasm-pack build --profile release-dist ...wasm-opt -Oz --all-featuresas a post-build pass when Binaryen is installed
If your bundler fails to serve WASM automatically, ensure kalam_client_bg.wasm is accessible and provide explicit module/path.
Timestamp utilities
parseIso8601(isoString)timestampNow()WasmTimestampFormatter
Useful for low-level time conversions aligned with Rust implementation.