Prompt
passkeys for web app
Latest observation
Oct 28, 2026
OpenAI APIWeb search: off
If you want to add passkeys to a web app, the modern approach is to use WebAuthn (FIDO2) on the frontend and a server-side registration/login flow.
What passkeys are
Passkeys let users sign in with:
- Face ID / Touch ID / Windows Hello / Android biometrics
- Device PIN
- Security keys
They replace passwords and are phishing-resistant.
Basic flow
1) Registration
- User signs up or chooses “Create passkey”
- Server creates a WebAuthn registration options challenge
- Browser calls
navigator.credentials.create(...) - Browser returns credential data
- Server verifies it and stores:
- credential ID
- public key
- sign counter
- user handle
2) Login
- User clicks “Sign in with passkey”
- Server creates a WebAuthn authentication options challenge
- Browser calls
navigator.credentials.get(...) - Browser returns assertion data
- Server verifies signature using stored public key
Frontend APIs
Registration
const credential = await navigator.credentials.create({
publicKey: optionsFromServer
});
Authentication
const assertion = await navigator.credentials.get({
publicKey: optionsFromServer
});
What your server must do
Your backend should:
- generate a cryptographically random challenge
- store it temporarily in session/cache
- verify origin, rpId, challenge, and signature
- store credential public key after registration
- look up the credential on login and verify assertion
Important requirements
- Your site must be served over HTTPS
localhostis allowed for development- Use the correct RP ID (usually your domain, e.g.
example.com) - Match the browser origin exactly
- Use a WebAuthn library instead of implementing crypto manually
Recommended libraries
Node.js
@simplewebauthn/server@simplewebauthn/browser
Python
webauthn
Go
go-webauthn
Java
webauthn4j
Example architecture
- Frontend: calls server for options, then uses WebAuthn browser APIs
- Backend: verifies registration/authentication and stores credentials
- Database: table for passkeys linked to user accounts
Example credential table:
iduser_idcredential_idpublic_keycountertransportscreated_at
Best practices
- Allow multiple passkeys per user
- Offer passkeys as primary login, but consider fallback recovery
- Support account linking to existing password accounts
- Use “discoverable credentials” if you want username-less login
- Keep good UX for platform vs cross-device authenticators
If you want, I can give you:
- a complete working example in Node/Express,
- a Next.js implementation, or
- a backend + frontend code sample for registration and login.