Skip to Content

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/client package API. If you want the supported high-level client, use createClient(...) from @kalamdb/client and follow the package docs instead of constructing KalamClient from @kalamdb/client/wasm directly.

Recommended high-level docs:

  • /docs/sdk/typescript/setup
  • /docs/sdk/typescript/subscriptions
  • /docs/sdk/typescript/client-lifecycle

Import low-level bindings

import init, { KalamClient, WasmTimestampFormatter, parseIso8601, timestampNow, initSync, } from '@kalamdb/client/wasm';

Initialization patterns

// async init await init(); // or explicit module/path await 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:8080', '<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:8080'); 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/wasm and dist/.wasm-out

Repository builds target a size-first WASM pipeline:

  • wasm-pack build --profile release-dist ...
  • wasm-opt -Oz --all-features as 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.

Last updated on