Skip to Content
WASM Entrypoint

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/ts-sdk/setup
  • /docs/ts-sdk/subscriptions
  • /docs/ts-sdk/client-lifecycle

Import low-level bindings

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

Initialization patterns

ts snippetTS
// 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.

ts snippetTS
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:

ts snippetTS
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/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