Biometric login
Prompt for Face ID, Touch ID, or fingerprint and read the result.
Prompt for biometric auth
Use biometrics as a local confirmation before a sensitive UI step. It is not payment authorization or proof of identity to your backend; scripts on the page can imitate a client-side result.
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.
Pass an optional reason string to show in the prompt.
A biometric result is local; never send it to a server as proof. Use your backend’s normal authentication and authorization.
Check getDeviceInfo()?.biometricsAvailable before prompting, and fall back to PIN/password when it's false. Wrap the call in try/catch.
Awaiting the call only confirms the prompt was requested. The actual success or failure arrives on the biometricResult event.
Read the result
Subscribe to biometricResult to learn whether auth succeeded. The BiometricResult payload has status ("success" or "failed"), data (the raw native auth result), and platform ("ios" | "android"). bdk.on(...) returns an unsubscribe function — call it when you're done.
A failed or cancelled prompt comes through biometricResult, not the error event, and does not reject the promise. Branch on status inside your listener.
Subscribe before you prompt
Register the biometricResult listener before calling authenticateBiometrics(), or a fast result can be missed.
Wait for device info before this call. On failure or timeout, offer your normal sign-in path; keep payment and session authorization on the backend.
See it running in the live demo, or every native feature with its demo on thebdk.com.