Skip to Content
RealtimeLive Queries

KalamDB Live Queries

Subscribe to your KalamDB todo table and render the latest rows whenever data changes. Start with an authenticated client and the todo schema.

Subscribe to KalamDB rows

TS
const unsubscribe = await client.liveTable(  'app.todos',  (rows) => setTodos(rows),);

Here client is your authenticated client and setTodos updates application state. The SDK materializes the initial rows and reconciles later inserts, updates, and deletes. Row fields are typed cells: render a title with row.title.asString() and a checkbox with row.completed.asBool(), or use mapRow to convert them into your UI model. Run an update from a second connection using the same identity to see the callback fire.

To subscribe only to incomplete tasks:

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

Stop the subscription when the view is disposed:

TS
await unsubscribe();

React applications should start with useLiveQuery(), which integrates subscriptions with component lifecycle.

Copy a complete live-query example

Common mistakes

Live SQL supports a restricted query shape. Do not put ORDER BY or LIMIT in the subscription SQL. Use the SDK’s supported options and sort your rendered rows if necessary. Use liveEvents() only when you need to handle raw events yourself.

For persistent offline state, use kalam_sync for Flutter. A browser callback by itself is not a durable local checkpoint.

Next step

Add a server procedure →

Reference: Reconnection and resume behavior.