Passkeys Explained: How to Add Passwordless Login to Your Website
December 5, 2026 · 11 min read

Passwords are the weakest link in online security. They get reused, guessed, phished and leaked in breaches, and people forget them at the worst moment, often in the middle of a purchase. Passkeys replace them with a cryptographic key pair stored on the user's phone, computer or password manager and unlocked with a fingerprint, face scan or device PIN. They cannot be phished, there is nothing to remember and nothing useful to steal from your servers. Support is now built into every major operating system and browser, and billions of passkeys are in use. This guide explains how passkeys work, what adoption looks like in 2026, and how to add passwordless login to your website step by step, with code.
What Is a Passkey?
A passkey is a credential based on public-key cryptography and the WebAuthn and FIDO2 standards. When a user creates one, their device generates a key pair: the private key stays on the device or in their password manager, and your website stores only the public key. To sign in, your site sends a random challenge; the device asks the user to unlock it with biometrics or a PIN, signs the challenge with the private key and returns the signature, which your server checks with the public key.
Three properties make this powerful. First, each passkey is bound to your website's domain, so a fake login page on a look-alike domain simply cannot use it: passkeys are phishing-resistant by design. Second, your database holds no secrets worth stealing, because public keys are useless to attackers. Third, the user's biometric data never leaves their device; it only unlocks the key locally. Passkeys sync across a user's devices through Apple, Google, Microsoft or third-party password managers, so losing a phone does not mean losing access.
Passkeys vs Passwords vs Two-Factor Codes
| Aspect | Password | Password plus SMS or app code | Passkey |
|---|---|---|---|
| Phishing resistance | None | Weak: codes can be phished in real time | Strong: bound to the real domain |
| Server breach impact | Hashes can be cracked | Hashes can be cracked | Only public keys exposed |
| User effort | Remember and type | Type, then wait for a code | Fingerprint, face or PIN |
| Reuse across sites | Common | Common | Impossible: unique per site |
| Recovery | Email reset | Email reset plus device | Synced to other devices; plus a fallback |
Our guide to two-factor authentication explains why one-time codes, while better than passwords alone, remain vulnerable to modern phishing kits.
Passkey Adoption in 2026
Passkeys have moved from early adopters to the mainstream. On World Passkey Day in May 2026, the FIDO Alliance reported an estimated 5 billion passkeys in use worldwide. In its survey of 11,000 consumers in ten countries, 90% were aware of passkeys, 75% had enabled at least one and 49% used them regularly when available. Nearly half said they were likely to abandon a purchase or sign-in when they could not remember a password, a direct cost to online businesses. Among large employers, 68% had deployed or were deploying passkeys for staff sign-in. In the United States, NIST's revised digital identity guidelines, SP 800-63-4, also recognise synced passkeys as acceptable for its second authentication assurance level, the level typically required for multi-factor sign-in.
How Passkey Sign-In Works
There are two "ceremonies":
- Registration. A signed-in user chooses "Create a passkey". Your server generates options, including a one-time challenge and your domain; the browser asks the device to create a key pair; the device returns the public key and a signed proof; your server verifies it and saves the public key against the user's account.
- Authentication. On the login page, the browser offers the user's passkeys for your site, often directly in the username field's autofill menu. The user picks one and unlocks it; the device signs your server's challenge; your server verifies the signature with the stored public key and starts a session.
Users can also sign in on a computer using a passkey stored on their phone by scanning a QR code, with Bluetooth confirming the two devices are physically close.
Adding Passkeys to Your Website, Step by Step
- Choose a library. Never implement WebAuthn verification yourself. For JavaScript and TypeScript, SimpleWebAuthn is a popular choice; most languages have equivalents, and authentication platforms such as Auth.js, Better Auth, Laravel's starter kits and managed identity providers include passkey support.
- Add a passkeys table storing, for each credential, the user ID, credential ID, public key, signature counter, creation date and a friendly name.
- Build the registration endpoints and offer "Create a passkey" after a normal sign-in and in account settings.
- Build the sign-in endpoints and enable autofill sign-in by adding
webauthnto the username field's autocomplete attribute. - Keep a fallback, such as email magic links or an existing password, while users transition.
- Let users manage passkeys: list, rename and delete them in account settings.
The Code: Server and Browser
Here are the four server routes in an Express app using SimpleWebAuthn, with a database helper object standing in for your own data layer:
// passkeys.mjs (server) - registration and sign-in routes with @simplewebauthn/server
import {
generateRegistrationOptions, verifyRegistrationResponse,
generateAuthenticationOptions, verifyAuthenticationResponse,
} from "@simplewebauthn/server";
const rpName = "Example Shop";
const rpID = "example.com"; // your domain: passkeys only work on this site
const origin = `https://${rpID}`;
export function passkeyRoutes(app, db) {
// 1. Registration: a signed-in user adds a passkey to their account
app.post("/auth/passkey/register/options", async (req, res) => {
const user = req.session.user;
const options = await generateRegistrationOptions({
rpName,
rpID,
userName: user.email,
excludeCredentials: (await db.passkeysFor(user.id)).map((p) => ({ id: p.id })),
authenticatorSelection: { residentKey: "required", userVerification: "preferred" },
});
req.session.challenge = options.challenge; // one-time challenge, checked on verify
res.json(options);
});
app.post("/auth/passkey/register/verify", async (req, res) => {
const { verified, registrationInfo } = await verifyRegistrationResponse({
response: req.body,
expectedChallenge: req.session.challenge,
expectedOrigin: origin,
expectedRPID: rpID,
});
if (!verified) return res.status(400).json({ error: "Registration failed" });
const { credential } = registrationInfo; // store the ID, public key and counter
await db.savePasskey(req.session.user.id, {
id: credential.id, publicKey: credential.publicKey, counter: credential.counter,
});
res.json({ ok: true });
});
// 2. Sign-in: no username needed, the browser offers the user's passkeys
app.post("/auth/passkey/options", async (req, res) => {
const options = await generateAuthenticationOptions({ rpID, userVerification: "preferred" });
req.session.challenge = options.challenge;
res.json(options);
});
app.post("/auth/passkey/verify", async (req, res) => {
const passkey = await db.findPasskey(req.body.id);
if (!passkey) return res.status(401).json({ error: "Unknown passkey" });
const { verified, authenticationInfo } = await verifyAuthenticationResponse({
response: req.body,
expectedChallenge: req.session.challenge,
expectedOrigin: origin,
expectedRPID: rpID,
credential: { id: passkey.id, publicKey: passkey.publicKey, counter: passkey.counter },
});
if (!verified) return res.status(401).json({ error: "Sign-in failed" });
await db.updateCounter(passkey.id, authenticationInfo.newCounter);
req.session.regenerate(() => { // new session ID after login prevents session fixation
req.session.userId = passkey.userId;
res.json({ ok: true });
});
});
}
And the browser side, which turns on passkey sign-in through the autofill menu when the browser supports it:
// login.js (browser) - passkey sign-in through autofill, using @simplewebauthn/browser.
// The username field needs: <input name="username" autocomplete="username webauthn">
import { browserSupportsWebAuthnAutofill, startAuthentication } from "@simplewebauthn/browser";
export async function setUpPasskeyAutofill() {
if (!(await browserSupportsWebAuthnAutofill())) return; // keep other sign-in options visible
const options = await (await fetch("/auth/passkey/options", { method: "POST" })).json();
// Passkeys now appear in the username field's autofill menu
const response = await startAuthentication({ optionsJSON: options, useBrowserAutofill: true });
const result = await fetch("/auth/passkey/verify", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify(response),
});
if (result.ok) window.location.assign("/account");
}
Note the important details: the challenge is generated per attempt and stored in the server session; verification checks the expected origin and domain, which is what defeats phishing; the signature counter is updated after each sign-in; and the session ID is regenerated after a successful login. In a React or Next.js app, the browser code sits in a client component, and the routes become route handlers or server functions.
User Experience Best Practices
- Prompt at the right moment: right after a successful password sign-in or account creation, with a short explanation such as "Sign in faster with your fingerprint or face".
- Use the word "passkey" consistently; it is the term operating systems and password managers show.
- Do not hide other options until most of your users have passkeys, and never trap a user without a recovery route.
- Support autofill, so returning users see their passkey as soon as they tap the username field.
- Test across platforms: iPhone, Android, Windows and Mac, in Safari, Chrome, Edge and Firefox, including the phone-as-authenticator flow.
Account Recovery and Edge Cases
Synced passkeys solve most "lost phone" problems, because the passkey is restored on a new device from the user's account with Apple, Google, Microsoft or their password manager. You still need a recovery process for users who lose everything: verified email with additional checks, recovery codes, or identity verification for high-value accounts. Encourage users to register more than one passkey, for example on a phone and a laptop. For workforce and high-security scenarios, hardware security keys and device-bound passkeys that do not sync offer extra assurance. Standards for securely moving passkeys between password managers are also rolling out, reducing lock-in for users.
Passkeys in Mobile Apps
Passkeys work in native apps too, and the same passkey can sign a user in on your website and in your iOS or Android app. On iOS, apps use Apple's AuthenticationServices framework; on Android, the Credential Manager API. Linking your app to your domain, through Apple's associated domains file and Android's Digital Asset Links, tells the operating system that the app and the website belong together, so passkeys created on one work on the other. Cross-platform frameworks such as Flutter and React Native have plugins that wrap these APIs. As with the web, keep a recovery route and test on real devices from several manufacturers.
A Phased Rollout Plan
- Phase one, optional: let users add a passkey in account settings and measure how many do.
- Phase two, prompted: invite users to create a passkey right after they sign in with a password, and enable autofill sign-in.
- Phase three, default: make passkeys the first option on the login page and for new accounts, keeping a fallback for everyone else.
- Measure throughout: track passkey adoption, sign-in success rate, time to sign in, password-reset requests and support tickets, and fix the drop-off points you find.
In the FIDO Alliance's 2026 survey, organisations that had deployed passkeys commonly reported faster logins and fewer password-reset tickets, benefits that help justify the work.
Security Beyond Sign-In
Passkeys protect the moment of sign-in, but attackers increasingly steal the session afterwards, using malware that copies cookies from a compromised computer. Protect sessions with secure cookie settings, short lifetimes and re-authentication for sensitive actions, as covered in our comparison of JWT vs session authentication. If you rely on "Sign in with Google" or an enterprise identity provider, passkeys usually apply at that provider, and your app receives tokens through the flows explained in our guide to OAuth 2.0 and OpenID Connect. For a broader view, see our guides to protecting your website from hackers and cybersecurity for small businesses.
Frequently Asked Questions
What are passkeys in simple terms?
Passkeys are a replacement for passwords. Your device creates a unique key for each website and unlocks it with your fingerprint, face or PIN, so you sign in without typing anything and fake websites cannot trick you.
Are passkeys safer than passwords?
Yes. Passkeys cannot be phished, reused or guessed, and websites store only public keys, so a data breach does not expose anything an attacker can use to sign in.
What happens to my passkeys if I lose my phone?
If your passkeys are synced through Apple, Google, Microsoft or a password manager, they are restored when you sign in to that account on a new device. Websites should also offer a recovery option.
Do passkeys work on all devices and browsers?
All major operating systems and browsers support passkeys. You can also use a passkey on your phone to sign in on another computer by scanning a QR code.
Does my website still need passwords if it supports passkeys?
During the transition, most sites keep a fallback such as a password or email link. Over time, you can make passkeys the default and offer passwordless accounts for users who have them.
How long does it take to add passkeys to a website?
With a mature library or authentication platform, a basic implementation can take days rather than weeks. Allow extra time for user experience, recovery flows and cross-device testing.
Go Passwordless With Confidence
We add passkeys, secure sessions and modern sign-in flows to websites and apps, with recovery and cross-device testing done properly. Contact our team to plan your passwordless login.