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.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/better-auth/better-auth/llms.txt
Use this file to discover all available pages before exploring further.
Installation
Add the server plugin
Import
passkey from @better-auth/passkey and add it to your plugins list:auth.ts
Run the database migration
The passkey plugin needs a
passkey table in your database:- migrate
- generate
Usage
Register a passkey
A user must be signed in before they can register a passkey. Callpasskey.addPasskey:
register-passkey.ts
Sign in with a passkey
CallsignIn.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:Add autocomplete attributes to inputs
Add
webauthn as the last value of the autocomplete attribute on your input fields: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 thepasskey() plugin:
auth.ts
| Option | Description |
|---|---|
rpID | Unique identifier for your site, based on the domain. localhost is valid for local development. |
rpName | Human-readable app name displayed in browser and OS prompts. |
origin | The origin URL where Better Auth is hosted. No trailing slash. |
authenticatorSelection | WebAuthn authenticator selection criteria. |
During local development you can omit
rpID, rpName, and origin. Better Auth defaults to localhost.