Skip to main content
Passkeys are a secure, passwordless authentication method based on WebAuthn and FIDO2 standards. Users authenticate using biometrics (fingerprint, Face ID), a device PIN, or a hardware security key — no password required. The passkey plugin is powered by SimpleWebAuthn under the hood.

Installation

1

Install the package

2

Add the server plugin

Import passkey from @better-auth/passkey and add it to your plugins list:
auth.ts
3

Run the database migration

The passkey plugin needs a passkey table in your database:
4

Add the client plugin

Import passkeyClient from @better-auth/passkey/client:
auth-client.ts

Usage

Register a passkey

A user must be signed in before they can register a passkey. Call passkey.addPasskey:
register-passkey.ts

Sign in with a passkey

Call signIn.passkey to prompt the user to authenticate:
sign-in.ts

Browser autofill (Conditional UI)

Conditional UI lets the browser automatically suggest passkeys in input fields. Two things are required:
1

Add autocomplete attributes to inputs

Add webauthn as the last value of the autocomplete attribute on your input fields:
2

Call signIn.passkey with autoFill on mount

sign-in.tsx

List passkeys

list-passkeys.ts

Delete a passkey

delete-passkey.ts

Update a passkey name

update-passkey.ts

Relying party configuration

Configure the relying party (RP) options in the passkey() plugin:
auth.ts
During local development you can omit rpID, rpName, and origin. Better Auth defaults to localhost.

Debugging

To test passkey registration and sign-in without a physical device, use Chrome’s emulated authenticators in DevTools.