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 Stephen November 30, 2026 13 min read
Passkeys for Web Apps in 2026: How to Implement Passwordless Login with WebAuthn

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

Real sitelogin.example.comorigin matches rp.idPasskey signs✓ login succeedsPhishing siteexamp1e-login.comorigin mismatchBrowser refuses✗ nothing to steal
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

FactorPasswordPassword + OTPPasskey
Phishing resistantNoNo (codes can be relayed)Yes (bound to origin)
Server stores a secretPassword hashHash + OTP seedPublic key only
Breach impactHighMediumVery low
User effortType + rememberType + wait for codeBiometric or PIN
Reset burdenFrequentFrequentRare with synced passkeys
Counts as MFANoYesYes (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.

BrowserYour Server (RP)Authenticator(phone / laptop / key)1. Request registration options2. challenge + rp.id + user.id3. navigator.credentials.create()4. User verifies (Face ID / PIN)5. Public key + attestation6. Send credential response7. Verify & store public key
  1. 1Server generates a random challenge and stores it in the session with a short expiry.
  2. 2Server returns options: RP name and ID, user handle, display name, supported algorithms (ES256 and RS256), and excludeCredentials to prevent duplicates.
  3. 3Browser calls navigator.credentials.create() and the user approves with Face ID, fingerprint or PIN.
  4. 4Server verifies the challenge, origin and RP ID, then stores the credential ID, public key, sign counter and transports.

5. Authentication flow

BrowserYour Server (RP)Authenticator1. Request login options2. Fresh random challenge3. navigator.credentials.get()4. Signature over challenge + origin5. Send assertion6. Verify signature → session

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

StackServer libraryNotes
Node.js / TypeScriptSimpleWebAuthnServer and browser packages, widely used
Python / Djangopy_webauthnMaintained by Duo Labs
PHP / Laravelweb-auth/webauthn-lib, laragear/webauthnLaragear integrates with Laravel auth
Gogo-webauthn/webauthnCommon in Go identity services
.NETFido2NetLibFIDO2 / 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
sign_count BIGINT NOT NULL DEFAULT 0,
transports TEXT[], -- usb, nfc, ble, internal, hybrid
backup_eligible BOOLEAN NOT NULL DEFAULT FALSE,
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:

<input type="text" name="username" autocomplete="username webauthn" />

Then start a conditional request when the login page loads:

if (window.PublicKeyCredential &&
await PublicKeyCredential.isConditionalMediationAvailable?.()) {
const options = await fetch("/webauthn/login/options").then(r => r.json());
const credential = await navigator.credentials.get({
publicKey: decodeOptions(options), // base64url → ArrayBuffer (your library does this)
mediation: "conditional",
});
await fetch("/webauthn/login/verify", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(encodeCredential(credential)),
});
}
UX tip
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

TypeWhere it livesStrengthGood fit
Synced passkeyCloud password manager across the user's devicesSurvives device loss, easy UXConsumer apps, most business users
Device-bound passkeySingle device or hardware security keyHighest assurance, cannot be copiedAdmins, 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.
  • Recovery codes: one-time codes, shown once, stored hashed.
  • 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

MistakeConsequenceFix
Reusing or not expiring challengesReplay attacksSingle-use, short-lived, server-stored challenges
Using email as user.idLeaks personal data to authenticatorsRandom 32–64 byte opaque handle
Wrong rp.id across subdomainsPasskeys fail on some hostsUse the registrable parent domain consistently
Skipping origin verificationWeakens phishing protectionVerify expected origin(s) on every response
Forcing passkeys on day oneLockouts and support loadOffer alongside passwords, then migrate
No passkey management pageStale devices remain trustedList, rename and revoke passkeys in settings

A practical rollout path

StageWhat to shipGoal
Stage 1Passkeys as optional second factor or alternative loginBuild confidence and test across devices
Stage 2Post-login "create a passkey" prompt + conditional UIDrive adoption with minimal friction
Stage 3Passkey management page and recovery codesMake passkeys self-service and resilient
Stage 4Passkey-first sign-in; password as fallbackReduce password usage and resets
Stage 5Passwordless for staff and admin rolesRemove 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.
Book a Consultation →
© Copyright 2024 Ajish Stephen