Saved login
Save, restore, and clear a user's email and password so returning users skip the login form.
Saved login
Examples reuse the single browser client from Set up the client. Adjust the ~/lib/bdk import to your app’s path; do not create a client in each component or handler.
Let returning users sign back in without re-typing their credentials. Methods live on bdk.auth, with one event for the response.
auth.updateCredentials({ email, password })— save credentials after login.auth.clearCredentials()— wipe saved credentials, e.g. on logout.auth.loginViaCredentials()— request saved credentials; they arrive on thesmartLoginCredentialsevent.
loginViaCredentials() doesn't return the credentials — read them from the smartLoginCredentials event.
Outside the native app the save/clear commands don't run. Branch on !result.triggered. To check support up front, read bdk.getDeviceInfo()?.smartLoginAvailable.
Save credentials after login
Call this right after a user authenticates so they sign in instantly next time.
Wrap the call in try/catch and report whether it completed. Do not treat a failed credential operation as a successful sign-in or sign-out.
Only save after you've verified the login is real.
The examples use your app’s showActionUnavailable() UI handler.
Clear saved credentials
Call this on logout to forget the saved login. Takes no arguments.
Wrap the call in try/catch and report whether it completed. Do not treat a failed credential operation as a successful sign-in or sign-out.
The examples use your app’s showActionUnavailable() UI handler.
Log in with saved credentials
On a returning visit, request the saved credentials. They arrive on the smartLoginCredentials event as { email: string | null; password: string | null }. If either field is null, nothing usable is saved — fall back to your login screen.
Register your smartLoginCredentials listener with bdk.on(...) before you call loginViaCredentials(), or you'll miss the response.
The examples use your app’s showActionUnavailable() UI handler.
See it running in the live demo, or every native feature with its demo on thebdk.com.