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
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:
Stop the subscription when the view is disposed:
React applications should start with useLiveQuery(), which integrates subscriptions with component lifecycle.
Copy a complete live-query example
- TypeScript inbox with startup errors and cleanup
- React inbox with typed mutations and retry
- Drizzle ORM live table
- Dart/Flutter inbox widget
- Rust inbox with explicit shutdown
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
Reference: Reconnection and resume behavior.