Auth-Aware Kalam Client for Flutter
For a new Flutter app, prefer kalam_sync and KalamScope. That handles lifecycle pause/resume and an account-scoped cache without a custom controller.
Use this page when you stay on kalam_link and need the client to follow login, token refresh, and logout.
Lifecycle
- Call
KalamClient.init()once beforerunApp(). - Connect after auth is ready — not before the first frame.
- Start live queries only after you know which user/session to subscribe.
- Dispose the client on logout.
Do not await KalamClient.connect() in main(). Even with lazy WebSocket connect, auth work can delay first render.
Riverpod example
On logout, dispose the client. On token rotation, keep the same client and call refreshAuth().
See Authentication, Realtime Subscriptions, and Client Lifecycle.
Last updated on