Home/Blog/Passkeys for Web Apps in 2026: How to Implement Passwordless Login with WebAuthn
Web Development
Passkeys for Web Apps in 2026: How to Implement Passwordless Login with WebAuthn
AJAjish StephenNovember 30, 202613 min read
Passwords remain the weakest part of most web applications. They get reused, phished, leaked in breaches and reset through support tickets. Passkeys replace them with public-key cryptography built into every major browser and operating system, and adoption has accelerated sharply as Apple, Google and Microsoft sync passkeys across devices and push users toward passwordless sign-in.
For developers, passkeys are no longer an experiment. They are a production-ready way to give users a faster login, remove password resets and make phishing attacks structurally ineffective. This guide explains how passkeys work, how to implement them with WebAuthn, and how to roll them out without locking anyone out.
Passkeys at a glance
Core idea
A passkey is a key pair. The private key never leaves the user's device or password manager; your server stores only the public key. Each login is a signature over a fresh challenge, bound to your domain — so there is no shared secret to steal, reuse or phish.
1. Why passkeys are trending now
Platform support is universal: modern versions of Chrome, Safari, Edge and Firefox support WebAuthn, and iOS, Android, macOS and Windows provide built-in passkey managers.
Passkeys sync: iCloud Keychain, Google Password Manager and third-party managers such as 1Password and Bitwarden sync passkeys, so losing a phone no longer means losing the account.
Cross-device sign-in: users can scan a QR code and approve a login on a nearby phone.
Phishing keeps winning: OTP codes and push approvals can be relayed by phishing kits; passkeys cannot.
Better conversion: one biometric prompt is faster than typing a password and waiting for an SMS code.
2. Passwords vs OTP vs passkeys
Factor
Password
Password + OTP
Passkey
Phishing resistant
No
No (codes can be relayed)
Yes (bound to origin)
Server stores a secret
Password hash
Hash + OTP seed
Public key only
Breach impact
High
Medium
Very low
User effort
Type + remember
Type + wait for code
Biometric or PIN
Reset burden
Frequent
Frequent
Rare with synced passkeys
Counts as MFA
No
Yes
Yes (device + biometric/PIN)
3. Key WebAuthn concepts
Relying Party (RP): your application. The rp.id is your domain, e.g. example.com, and passkeys only work on that domain and its subdomains.
Challenge: a random, single-use value generated by the server for every registration and login. It prevents replay attacks.
User handle: a random, opaque user.id — never an email address or other personal data.
Credential ID: identifies a specific passkey; one user can have several.
User verification: the authenticator confirms the user with biometrics or a device PIN.
Discoverable credential: a passkey stored with the user handle, enabling login without typing a username.
4. Registration flow
Registration creates a new key pair on the user's authenticator and gives your server the public key.
1Server generates a random challenge and stores it in the session with a short expiry.
2Server returns options: RP name and ID, user handle, display name, supported algorithms (ES256 and RS256), and excludeCredentials to prevent duplicates.
3Browser calls navigator.credentials.create() and the user approves with Face ID, fingerprint or PIN.
4Server verifies the challenge, origin and RP ID, then stores the credential ID, public key, sign counter and transports.
5. Authentication flow
On login, the server sends a fresh challenge, the authenticator signs it, and the server verifies the signature with the stored public key. If verification succeeds, create a normal session exactly as you would after a password login.
Important
Always verify the challenge, origin, RP ID hash, user-present and user-verified flags, and signature on the server. Use a maintained library for this rather than parsing CBOR and COSE keys yourself.
6. Use a proven library
Stack
Server library
Notes
Node.js / TypeScript
SimpleWebAuthn
Server and browser packages, widely used
Python / Django
py_webauthn
Maintained by Duo Labs
PHP / Laravel
web-auth/webauthn-lib, laragear/webauthn
Laragear integrates with Laravel auth
Go
go-webauthn/webauthn
Common in Go identity services
.NET
Fido2NetLib
FIDO2 / WebAuthn for ASP.NET Core
7. Store credentials correctly
Each user can own several passkeys — a phone, a laptop and a hardware key. Model them as a separate table.
CREATE TABLE webauthn_credentials (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
credential_id BYTEA NOT NULL UNIQUE, -- raw ID from the authenticator
public_key BYTEA NOT NULL, -- COSE-encoded public key
backed_up BOOLEAN NOT NULL DEFAULT FALSE, -- synced passkey?
nickname VARCHAR(100), -- "MacBook", "Pixel 9"
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
last_used_at TIMESTAMPTZ
);
CREATE INDEX idx_webauthn_user ON webauthn_credentials(user_id);
Public keys are not secrets, but credential rows still deserve normal access control and audit logging.
Store the backup flags: a synced passkey is far less likely to be lost than a device-bound one.
Let users name passkeys and see the last-used date so they can remove old devices.
8. Enable passkey autofill (conditional UI)
Conditional UI shows saved passkeys in the browser's autofill dropdown on your normal username field. Users who have a passkey sign in with one tap; everyone else keeps typing as usual. Add webauthn to the autocomplete attribute:
After a successful password login, prompt users to create a passkey: "Sign in faster next time with Face ID or fingerprint." This post-login upgrade prompt is one of the most effective ways to drive adoption.
9. Synced vs device-bound passkeys
Type
Where it lives
Strength
Good fit
Synced passkey
Cloud password manager across the user's devices
Survives device loss, easy UX
Consumer apps, most business users
Device-bound passkey
Single device or hardware security key
Highest assurance, cannot be copied
Admins, finance, regulated access
Most applications should accept both. For privileged roles, you can require device-bound keys or stronger attestation as a policy decision.
10. Account recovery without reopening the back door
Recovery is where many passwordless rollouts quietly reintroduce weak security. If anyone can reset access with an email link, attackers will target that path instead.
Encourage multiple passkeys: prompt users to register a second device.
Rely on sync: synced passkeys remove most lost-device scenarios.
Step-up recovery for high-risk accounts: identity verification or admin-assisted recovery.
Notify on changes: email users whenever a passkey is added or removed.
11. Common implementation mistakes
Mistake
Consequence
Fix
Reusing or not expiring challenges
Replay attacks
Single-use, short-lived, server-stored challenges
Using email as user.id
Leaks personal data to authenticators
Random 32–64 byte opaque handle
Wrong rp.id across subdomains
Passkeys fail on some hosts
Use the registrable parent domain consistently
Skipping origin verification
Weakens phishing protection
Verify expected origin(s) on every response
Forcing passkeys on day one
Lockouts and support load
Offer alongside passwords, then migrate
No passkey management page
Stale devices remain trusted
List, rename and revoke passkeys in settings
A practical rollout path
Stage
What to ship
Goal
Stage 1
Passkeys as optional second factor or alternative login
Build confidence and test across devices
Stage 2
Post-login "create a passkey" prompt + conditional UI
Drive adoption with minimal friction
Stage 3
Passkey management page and recovery codes
Make passkeys self-service and resilient
Stage 4
Passkey-first sign-in; password as fallback
Reduce password usage and resets
Stage 5
Passwordless for staff and admin roles
Remove phishable credentials where risk is highest
Passkey implementation checklist
✓ Challenges are random, single-use, server-stored and short-lived.
✓ The user handle is random and contains no personal data.
✓ The RP ID and expected origins are configured consistently across environments.
✓ Server-side verification uses a maintained WebAuthn library.
✓ Each user can register, name, view and revoke multiple passkeys.
✓ Conditional UI autofill is enabled on the login form.
✓ Users are prompted to create a passkey after a successful password login.
✓ Recovery codes or an equivalent secure recovery path exist.
✓ Users are notified when passkeys are added or removed.
✓ Privileged roles have a stronger passkey policy.
✓ Login success, failure and fallback rates are monitored.
Common questions
What is a passkey?
A passkey is a passwordless credential based on public-key cryptography. The private key stays on the user's device or password manager, the server stores only the public key, and the user unlocks it with a biometric or device PIN.
Are passkeys more secure than passwords with OTP?
Yes. Passkeys are bound to your domain, so phishing sites cannot use them, and the server stores no shared secret that can be stolen in a breach. OTP codes can still be phished and relayed in real time.
What happens if a user loses their phone?
Synced passkeys are restored from the user's password manager on a new device. For device-bound passkeys, users should have a second passkey or recovery codes.
Do passkeys count as multi-factor authentication?
Generally yes. A passkey combines possession of the device with biometric or PIN user verification, which is why many organizations treat it as phishing-resistant MFA.
Should I remove passwords immediately?
No. Offer passkeys alongside existing login methods first, encourage adoption with autofill and post-login prompts, then move to passkey-first sign-in once most active users have one.
Passkeys solve problems that passwords and one-time codes never could: there is nothing to reuse, nothing to phish and nothing valuable to steal from your database.
Start by offering passkeys alongside your current login, use a proven WebAuthn library, design recovery carefully, and let autofill and post-login prompts do the adoption work. Within a few release cycles, passwordless can become the default way your users sign in.
Planning passwordless login for your application?
I help teams implement secure authentication, passkeys, MFA, API security and production-ready web platforms.