Passwordless sign-in
An application wants users to authenticate without passwords using biometrics, device PINs, or security keys.
Better Auth · Function
Better Auth's passkey plugin enables passwordless WebAuthn authentication using device-stored credentials. Configure the plugin, update the database schema, and use client methods to register, sign in with, or manage passkeys.
The passkey plugin adds WebAuthn-based passwordless authentication. After configuring it and updating the database schema, an authenticated user can register passkeys, sign in with one, list their passkeys, or enable autofill for sign-in.
passkey()import { betterAuth } from "better-auth";
import { passkey } from "@better-auth/passkey";
import { createAuthClient } from "better-auth/client";
export const auth = betterAuth({ plugins: [passkey()] });
const authClient = createAuthClient();
await authClient.signIn.passkey();Install the plugin, register it in the server configuration, then invoke the client method to begin passkey sign-in.
An application wants users to authenticate without passwords using biometrics, device PINs, or security keys.
An authenticated user needs to add another device or security key.
A user needs to view the credentials associated with their account.
A frontend should offer passkey sign-in automatically when supported by the browser.
Passkeys use WebAuthn-compatible cryptographic key pairs instead of passwords. The private key remains on the user's device, while the public key is associated with the website.
Follow-up: Why are passkeys resistant to phishing? The credential is bound to the relying party, so a fraudulent site cannot use the legitimate site's credential.
Install @better-auth/passkey and add passkey() to the plugins array in betterAuth. Then migrate or generate the schema so the required passkey storage is available.
Follow-up: What must be done before registration? The user must already be authenticated.
Use authClient.signIn.passkey() to start passkey authentication. The same client API provides passkey.addPasskey for registration and listUserPasskeys for retrieving the authenticated user's passkeys.
Follow-up: How can passkey sign-in be prepared when a component loads? Call authClient.signIn.passkey with autoFill set to true.
passkey.addPasskeysignIn.passkeypasskey.listUserPasskeysautoFillSimpleWebAuthnWebAuthnFIDO2