Skip to Content
SDK & ClientTypeScript SDKSetup & Quick Start

Setup & Quick Start

Status: This SDK is in alpha and is subject to change between releases.

Looking to use Rust instead of TypeScript/JavaScript?

Install

npm i kalam-link

Runtime requirements:

  • Node.js >= 18 (or modern browser)
  • running KalamDB server (http://localhost:8080 by default)

First client

import { createClient, Auth } from 'kalam-link'; const client = createClient({ url: 'http://localhost:8080', auth: Auth.basic('admin', 'AdminPass123!'), });

This createClient(...) style is the canonical SDK entrypoint used across the TypeScript docs.

Connect and query

await client.login(); // exchanges basic credentials for JWT await client.connect(); const result = await client.query('SELECT CURRENT_USER()'); console.log(result.status, result.results[0]);

Notes:

  • query() works over HTTP and does not require a WebSocket connection.
  • By default (autoConnect: true), subscribe() / subscribeWithSql() will call connect() automatically on first use.

Parameterized query

Use $1, $2, … placeholders:

const filtered = await client.query( 'SELECT * FROM app.messages WHERE conversation_id = $1 AND is_deleted = $2', ['conv_42', false], );

First live subscription

const unsubscribe = await client.subscribe('app.messages', (event) => { if (event.type === 'change') { console.log(event.change_type, event.rows); } }); // Later await unsubscribe(); await client.disconnect();

Optional WASM path override

In environments where auto-WASM resolution fails, pass wasmUrl:

const client = createClient({ url: 'http://localhost:8080', auth: Auth.basic('admin', 'AdminPass123!'), wasmUrl: '/wasm/kalam_link_bg.wasm', });

Common startup pitfalls

  • connect() before query subscriptions is recommended (query alone initializes automatically).
  • If browser bundling cannot find WASM, provide wasmUrl explicitly.
  • For local dev auth, confirm server credentials and URL first.

Next

Last updated on