Biometric login

Prompt for Face ID, Touch ID, or fingerprint and read the result.

Prompt for biometric auth

Gate a sensitive action behind Face ID, Touch ID, or fingerprint. Use it before revealing a recovery phrase, confirming a payment, or unlocking a screen. Pass options your native build expects (e.g. a reason string).

Check getDeviceInfo()?.biometricsAvailable before prompting, and fall back to PIN/password when it's false.

Awaiting the call only confirms the prompt was requested. The actual success or failure arrives on the biometricResult event.

import { createBdkNative } from "@bdk/native/browser";

const bdk = createBdkNative();

// Dispatches authenticateBiometrics_ios or _android based on the device OS.
await bdk.auth.authenticateBiometrics();

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.

const off = bdk.on("biometricResult", ({ data, status, platform }) => {
  if (status === "success") {
    console.log(`Authenticated on ${platform}`, data);
    // Unlock the protected action here.
  } else {
    console.warn("Biometric auth did not succeed:", status, data);
  }
});

// Later, when you're done listening:
off();

Subscribe before you prompt

Register the biometricResult listener before calling authenticateBiometrics(), or a fast result can be missed.

import { createBdkNative } from "@bdk/native/browser";

const bdk = createBdkNative();

function unlockWithBiometrics() {
  return new Promise<boolean>((resolve) => {
    // 1. Subscribe FIRST so no result is missed.
    const off = bdk.on("biometricResult", ({ status }) => {
      off();
      resolve(status === "success");
    });

    // 2. Then dispatch the prompt.
    void bdk.auth.authenticateBiometrics({
      reason: "Unlock your account"
    });
  });
}

const ok = await unlockWithBiometrics();