Skip to Content

KalamDB Live Queries

Keep a screen up to date with an initial set of rows followed by inserts, updates, and deletes. Start with an authenticated client and a table created in Choosing Table Types.

Subscribe to KalamDB rows

For a table named app.todos, the TypeScript client can maintain the current rows for you:

TS
const unsubscribe = await client.liveTable('app.todos', (rows) => {  const todos = rows.map((row) => ({    id: row.id.asString(),    title: row.title.asString(),    completed: row.completed.asBool(),  }));  console.log(todos);});

client is your authenticated KalamDB client. Change a row from a second connection using the same identity and the callback receives the updated result. A USER table subscription stays within the authenticated user’s data.

Use SQL when you only want part of the table:

TS
const unsubscribe = await client.live(  'SELECT id, title, completed FROM app.todos WHERE completed = FALSE',  (rows) => console.log(rows),);

The high-level SDK reconciles changes into rows. Use liveEvents() only when you need to process protocol events yourself.

Choose your application integration

ApplicationGuide
TypeScript or Node.jsLive subscriptions
ReactuseLiveQuery and component lifecycle
RustRust live subscriptions
Dart or FlutterDart live subscriptions
Flutter with a persistent local cacheKalam Sync

Query limits and cleanup

Live SQL supports a single table and supported WHERE predicates. Do not put joins, aggregates, ORDER BY, or LIMIT in the live SQL. Sort the resulting rows in your UI and use the SDK’s materialization options when you need a bounded view.

Stop a subscription when its view closes or the user changes accounts:

TS
await unsubscribe();

Low-level result fields are typed cells, so convert them with accessors such as asString() and asBool() before rendering. Generated table clients can provide a typed application model.

Next step

Handle reconnection and resume →

Reference: Subscription SQL and supported query shapes.