Setup & Quick Start
Looking to use Rust instead of TypeScript/JavaScript?
Install
npm i kalam-linkRuntime requirements:
- Node.js
>= 18(or modern browser) - running KalamDB server (
http://localhost:8080by default)
First client
import { createClient, Auth } from 'kalam-link';
const client = createClient({
url: 'http://localhost:8080',
auth: Auth.basic('root', ''),
});Connect and query
await client.connect();
const result = await client.query('SELECT CURRENT_USER()');
console.log(result.status, result.results[0]);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('root', ''),
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
wasmUrlexplicitly. - For local dev auth, confirm server credentials and URL first.
Next
Last updated on