Passkeys for Websites: A Developer's Guide to Passwordless Login With WebAuthn
Passwords are the weakest link in web security. Passkeys replace them with phishing-resistant cryptography. Here is how they work and how to implement them.

Passkeys for Websites: A Developer's Guide to Passwordless Login With WebAuthn
Stolen and reused passwords remain one of the most common causes of account takeovers. One-time passwords by SMS help, but they can be phished or intercepted.
Passkeys offer a better approach: sign-in that is faster for users and resistant to phishing by design. Major platforms, browsers and password managers now support them, making it practical for any website to adopt.
What Is a Passkey?
A passkey is a credential based on public-key cryptography, built on the FIDO2 standards and the Web Authentication (WebAuthn) API.
- A private key stays on the user's device or in their password manager
- A public key is stored by your website
- The user unlocks the passkey with a fingerprint, face scan or device PIN
Your server never stores a secret that can be stolen and reused elsewhere.
Why Passkeys Resist Phishing
Each passkey is bound to your website's domain. If a user is tricked into visiting a fake site, the browser will not offer the passkey for that domain. There is no code or password to type into a phishing page.
Passkeys vs Passwords vs OTP
| Feature | Password | SMS OTP | Passkey |
|---|---|---|---|
| Phishing-resistant | No | No | Yes |
| Reused across sites | Often | N/A | Never |
| Server breach exposes usable secret | Yes (if weakly hashed) | No | No |
| User effort | Remember/type | Wait for SMS | Biometric/PIN |
| Cost | Low | Per-SMS cost | Low |
How the Flow Works
Registration (creating a passkey)
- Server generates a random challenge and sends registration options
- Browser calls
navigator.credentials.create() - User verifies with biometrics or PIN
- Device creates a key pair and returns the public key and attestation data
- Server verifies the response and stores the public key with the user account
const credential = await navigator.credentials.create({
publicKey: {
challenge: serverChallenge, // from your server
rp: { name: "Example", id: "example.com" },
user: {
id: userIdBytes,
name: "user@example.com",
displayName: "Asha"
},
pubKeyCredParams: [{ type: "public-key", alg: -7 }],
authenticatorSelection: {
residentKey: "required",
userVerification: "preferred"
}
}
});
// Send credential to server for verificationSign-in (using a passkey)
- Server sends a new challenge
- Browser calls
navigator.credentials.get() - User verifies with biometrics or PIN
- Device signs the challenge with the private key
- Server verifies the signature with the stored public key
const assertion = await navigator.credentials.get({
publicKey: {
challenge: serverChallenge,
rpId: "example.com",
userVerification: "preferred"
}
});
// Send assertion to server for verificationAlways verify on the server using a well-maintained WebAuthn library rather than writing cryptographic checks yourself.
Conditional UI: Passkeys in the Autofill Menu
Conditional mediation lets browsers show available passkeys in the username field's autofill suggestions:
<input type="text" name="username" autocomplete="username webauthn">Combined with mediation: "conditional" in navigator.credentials.get(), users can sign in with one tap, without a separate "Sign in with passkey" button.
Synced vs Device-Bound Passkeys
- Synced passkeys are backed up through platform password managers and available across a user's devices
- Device-bound passkeys stay on a single device or hardware security key — common in high-security environments
Account Recovery: Plan It Carefully
Passkeys reduce lost-password problems, but users still lose devices. Offer:
- Multiple registered passkeys per account
- Verified email or phone recovery with extra checks
- Clear account settings to view and remove passkeys
UX Best Practices
- Offer passkey creation after a successful login, when users are already authenticated
- Use clear language: "Sign in faster with your fingerprint or face"
- Keep existing methods during the transition
- Let users name and manage their passkeys
- Track adoption and sign-in success rates
Rollout Strategy
- Phase 1: Add passkeys as an optional sign-in method
- Phase 2: Prompt active users to create passkeys
- Phase 3: Make passkeys the default for new sign-ups
- Phase 4: Reduce reliance on passwords and SMS OTP where appropriate
Frequently Asked Questions
Are passkeys the same as biometric login?
Biometrics only unlock the passkey locally. Your fingerprint or face data is not sent to the website.
What happens if a user loses their phone?
Synced passkeys can be restored through the user's password manager. Websites should also provide secure recovery options.
Do passkeys work across browsers?
Modern browsers and operating systems support passkeys, and cross-device sign-in lets users authenticate using a phone near their computer.
Do passkeys eliminate the need for MFA?
A passkey with user verification combines something you have (the device) with something you are or know (biometric or PIN), so it is itself a strong multi-factor method.
Conclusion
Passkeys are one of the rare security upgrades that also improve user experience. For websites handling accounts, payments or personal data, adopting them is one of the most effective steps available to reduce phishing and account takeovers.
Wipidia Editorial Review Board
✓ Fact-Checked & VerifiedThis article was authored and reviewed by Wipidia's technical editorial desk in Jalandhar, Punjab. Every code snippet, algorithm breakdown, and strategic framework is independently tested against live production standards before publication.

