Passkeys vs Passwords: WebAuthn Implementation Guide

Passkeys vs passwords compared, plus a WebAuthn implementation guide: registration, login, server checks, attestation and safe recovery.

Ketan PatelCodesClue Updated 14 min read

Your users forget passwords, reuse them and type them into fake login pages. Your support team then resets them every week. Passkeys fix both problems, and your users’ browsers already support them. This guide compares passkeys vs passwords and shows how to build passkey sign-in with WebAuthn, server checks included.

Key Takeaways

  • A password is a secret your server also knows. A passkey is a key pair, and your server only keeps the public half.
  • Passkeys resist phishing because the browser ties each one to your domain. A look-alike site cannot ask for it.
  • WebAuthn has two ceremonies: registration creates the passkey and authentication uses it. Each one needs a fresh random challenge from your server.
  • Most consumer apps should ask for no attestation, prefer user verification and expect synced passkeys to report a signature counter of zero.
  • Keep a safe fallback. Users lose phones, so plan recovery before you switch off passwords.

Passkeys vs passwords: the short answer

In passkeys vs passwords, the passkey wins on security and speed. A password is a shared secret people can guess, reuse or hand to a phishing page. A passkey is a private key that stays on the user’s device. Your server keeps only a public key, so a database leak gives attackers nothing to log in with.

Passwords still win on one point: every system on earth supports them. That is why most teams run both for a while. The table below sets out passkeys vs passwords on the points your users and your support team feel.

Passkeys vs passwords compared side by side

Question Passwords Passkeys
What your server keeps A hash of the secret. Weak passwords fall to offline cracking after a leak. A public key. It cannot sign anything on its own.
Phishing A fake page can collect the password and replay it. The browser only offers the passkey on the domain it belongs to.
Reuse across sites Common, so one leak opens many accounts Impossible. Each site gets its own key pair.
What the user does Remembers, types and resets Confirms with a fingerprint, face scan or device PIN
Recovery Email reset link Synced copy in the password manager, a second passkey or your own recovery flow
Support Every browser, app and legacy system Modern browsers and operating systems. Older devices may need a fallback.

Why passwords keep failing

Why passwords keep failing businesses

The core problem is simple. A password works anywhere someone types it, and that includes a fake login page. Your server has to compare it with something it stores, so a leak of that store puts every account at risk.

People also pick short passwords and use them on many sites. Rules about length and symbols push users toward sticky notes and the same password with a “1” at the end.

Microsoft shared real numbers on passkeys vs passwords. In its May 2025 security blog post (opens in a new tab), it reported that about 98% of passkey sign-ins succeed, against 32% for passwords. It also said passkey sign-ins run eight times faster than a password plus a second factor.

Pro tip: Before you build anything, pull your own numbers. Count password reset emails and failed logins for one month. Those two figures become the baseline that proves your passkey work paid off.

How passkeys work under the hood

A passkey is a public key credential made under the FIDO2 standards. Your device creates two keys for each site. The private key signs a random challenge from your server. The public key lets your server check that signature.

What passkeys actually are: a private key on the device and a public key on the server

The user opens the private key with a fingerprint, a face scan or the device PIN. That check happens on the device. Your server never sees the fingerprint or the PIN.

Phishing protection comes from the relying party ID, or RP ID. That is the domain a passkey belongs to, such as example.com. The browser puts the page origin into the signed data and only offers passkeys whose RP ID matches. A clone at example-login.net gets nothing to replay.

WebAuthn and CTAP: who does what

FIDO2 passkey architecture with WebAuthn and CTAP

FIDO2 has two parts. WebAuthn is the browser API your code calls, through navigator.credentials.create() and navigator.credentials.get(). CTAP is the protocol the browser uses to talk to an outside authenticator. That might be a hardware security key on a cable, or a phone nearby over Bluetooth.

The W3C Web Authentication Level 3 specification (opens in a new tab) became a W3C Recommendation on 25 August 2026. It also adds helpers that make your code shorter, such as parseCreationOptionsFromJSON() and getClientCapabilities().

Synced and device-bound passkeys

The FIDO Alliance enterprise passkey paper (opens in a new tab) describes two kinds. Synced passkeys copy key material through a cloud service, such as iCloud Keychain or Google Password Manager. Device-bound passkeys never leave one device, such as a hardware security key.

Both kinds count as passkeys. The difference matters for recovery and for policy.

Point Synced passkey Device-bound passkey
Lost phone The user signs in on a new device from the same account You need a second key or a recovery flow
Backup flags in the response BE (backup eligible) on, BS (backup state) usually on BE off and BS off
Signature counter Often stays at zero Usually counts up on each use
Best fit Consumer apps, SaaS sign-in Administrators, regulated staff accounts, shared kiosks with personal keys

WebAuthn implementation, step by step

A sound WebAuthn implementation has seven parts. Build them in this order, because each step depends on the one before it.

How to implement passkeys step by step

  1. Pick your RP ID and the origins you accept.
  2. Add a table for passkey credentials.
  3. Write the registration ceremony.
  4. Build the authentication ceremony.
  5. Turn on passkey autofill in the login form.
  6. Design the fallback and recovery path.
  7. Test with virtual authenticators before real devices.

Do not write the signature and CBOR parsing yourself. Use a maintained library such as SimpleWebAuthn for Node.js, py_webauthn for Python or go-webauthn for Go. The examples below use SimpleWebAuthn version 14, the current release. In the browser code, postJSON() is a small helper that sends JSON with fetch() and returns the parsed reply.

Step 1: Pick your RP ID and origins

Your RP ID is usually your main domain without the scheme, such as example.com. MDN (opens in a new tab) explains the rule: the RP ID must equal the page’s domain or a parent of it. A passkey made with RP ID example.com then works on login.example.com and app.example.com.

Choose it once. Changing the RP ID later breaks every passkey your users already made. If your products live on separate domains, Level 3 adds related origins. You list the allowed origins in a JSON file at /.well-known/webauthn on the RP ID domain.

Native apps need one more step. On iOS, Apple’s passkey guide (opens in a new tab) requires an associated domain with the webcredentials service type. Without it, registration and sign-in requests return an error.

Step 2: Store credentials in their own table

One user can hold many passkeys: a phone, a laptop and a hardware key. Give them their own table, keyed by credential ID.

CREATE TABLE passkeys (
  id            TEXT PRIMARY KEY,        -- credential ID, base64url
  user_id       UUID NOT NULL REFERENCES users(id),
  public_key    BYTEA NOT NULL,
  counter       BIGINT NOT NULL DEFAULT 0,
  transports    TEXT[],
  device_type   TEXT NOT NULL,           -- singleDevice or multiDevice
  backed_up     BOOLEAN NOT NULL,
  aaguid        TEXT,                    -- names the passkey provider
  created_at    TIMESTAMPTZ DEFAULT now(),
  last_used_at  TIMESTAMPTZ
)

Give each user a separate WebAuthn user handle too. Google’s server-side registration guide (opens in a new tab) says this ID should be random, permanent and free of personal data. The spec caps it at 64 bytes.

Pro tip: Store the AAGUID and show it as a provider name on the account page, such as “Google Password Manager” or “iCloud Keychain”. Users can then see which passkey to delete when they sell a phone.

Step 3: Write the registration ceremony

Registration creates the passkey. Your server sends options with a fresh challenge, the browser asks the user to confirm, and your server checks the reply.

// server: registration options
import { generateRegistrationOptions, verifyRegistrationResponse } from '@simplewebauthn/server'
const rpID = 'example.com'
const origin = 'https://example.com'
app.post('/passkeys/register/options', async (request, reply) => {
  const user = request.user
  const existing = await db.passkeys.findByUser(user.id)
  const options = await generateRegistrationOptions({
    rpName: 'Example',
    rpID,
    userName: user.email,
    userID: user.webauthnId,             // random bytes, no personal data
    attestationType: 'none',
    excludeCredentials: existing.map(c => ({ id: c.id, transports: c.transports })),
    authenticatorSelection: { residentKey: 'required', userVerification: 'preferred' }
  })
  request.session.challenge = options.challenge
  reply.json(options)
})

Three settings matter here. The residentKey: 'required' value makes a discoverable credential, so the user can sign in without typing a username. The excludeCredentials list stops a second passkey on a provider that already holds one. Finally, attestationType: 'none' skips the device model check, which most consumer apps do not need.

In the browser, turn the JSON options into the binary form and call create().

// browser: create the passkey
const json = await postJSON('/passkeys/register/options')
const credential = await navigator.credentials.create({
  publicKey: PublicKeyCredential.parseCreationOptionsFromJSON(json)
})
await postJSON('/passkeys/register/verify', credential.toJSON())

MDN marks parseCreationOptionsFromJSON() as Baseline 2025. For older browsers, the @simplewebauthn/browser package does the same conversion.

Back on the server, verify the reply and save the new credential.

// server: verify and save
app.post('/passkeys/register/verify', async (request, reply) => {
  const expectedChallenge = request.session.challenge
  delete request.session.challenge       // one use only, pass or fail
  const { verified, registrationInfo } = await verifyRegistrationResponse({
    response: request.body,
    expectedChallenge,
    expectedOrigin: origin,
    expectedRPID: rpID,
    requireUserVerification: false
  })
  if (!verified) return reply.status(400).end()
  const { credential, credentialDeviceType, credentialBackedUp, aaguid } = registrationInfo
  await db.passkeys.insert({
    id: credential.id,
    userId: request.user.id,
    publicKey: credential.publicKey,
    counter: credential.counter,
    transports: credential.transports,
    deviceType: credentialDeviceType,
    backedUp: credentialBackedUp,
    aaguid
  })
  reply.json({ ok: true })
})

Before you insert, check that no other account already owns this credential ID. Google’s guide lists that check, and it blocks a rare but nasty account mix-up.

Step 4: Build the authentication ceremony

Authentication uses the passkey. Your server sends a new challenge, the device signs it, and your server checks the signature with the stored public key.

// server: sign-in options and verification
import { generateAuthenticationOptions, verifyAuthenticationResponse } from '@simplewebauthn/server'
app.post('/passkeys/login/options', async (request, reply) => {
  const options = await generateAuthenticationOptions({ rpID, userVerification: 'preferred' })
  request.session.challenge = options.challenge
  reply.json(options)
})
app.post('/passkeys/login/verify', async (request, reply) => {
  const expectedChallenge = request.session.challenge
  delete request.session.challenge
  const passkey = await db.passkeys.findById(request.body.id)
  if (!passkey) return reply.status(401).end()
  const { verified, authenticationInfo } = await verifyAuthenticationResponse({
    response: request.body,
    expectedChallenge,
    expectedOrigin: origin,
    expectedRPID: rpID,
    credential: {
      id: passkey.id,
      publicKey: passkey.publicKey,
      counter: passkey.counter,
      transports: passkey.transports
    },
    requireUserVerification: false
  })
  if (!verified) return reply.status(401).end()
  await db.passkeys.update(passkey.id, {
    counter: authenticationInfo.newCounter,
    backedUp: authenticationInfo.credentialBackedUp,
    lastUsedAt: new Date()
  })
  request.session.userId = passkey.userId    // start the session
  reply.json({ ok: true })
})

The options leave allowCredentials empty on purpose. With discoverable passkeys, the browser lists every passkey for your RP ID and the user picks one. The library then checks the challenge, the origin, the RP ID hash, the user presence flag and the signature for you.

Two checks stay in your hands. Look up the credential by its ID, and confirm the user handle in the reply matches that credential’s owner. Then start the session only for that owner.

Step 5: Turn on passkey autofill

Passkey autofill, also called conditional UI, shows passkeys in the browser’s username suggestions. Users do not need a separate “Sign in with a passkey” button.

<input type="text" name="username" autocomplete="username webauthn">
// browser: run when the sign-in page loads
const caps = await PublicKeyCredential.getClientCapabilities()
if (caps.conditionalGet) {
  const json = await postJSON('/passkeys/login/options')
  const credential = await navigator.credentials.get({
    mediation: 'conditional',
    publicKey: PublicKeyCredential.parseRequestOptionsFromJSON(json)
  })
  await postJSON('/passkeys/login/verify', credential.toJSON())
}

Google’s passkey autofill guide (opens in a new tab) says to start this call when the page loads, not on a click. It also suggests an AbortController, so you can cancel the waiting request if the user picks another sign-in method.

Pro tip: After a user signs in with a password, offer to create a passkey right then. The user just proved who they are, so the moment feels natural. You also avoid a separate setup screen nobody visits.

Step 6: Design the fallback and recovery path

Recovery is where most passkey projects get hard. A synced passkey survives a lost phone. A device-bound key does not, and some users will never set up a second one.

  • Ask users to add a second passkey after the first, ideally on another device or provider.
  • Keep one recovery route, such as single-use recovery codes or a verified email link with a short expiry.
  • Treat recovery as a sign-in. Add rate limits, alerts to the user and a fresh passkey prompt once they are back in.
  • Keep passwords as an option until your data shows most active users hold a passkey.

A weak recovery flow undoes the work. If an attacker can reset an account with an SMS code, your phishing protection stops at that door.

Step 7: Test with virtual authenticators

Chrome DevTools has a WebAuthn panel (opens in a new tab) that emulates authenticators. You can add a virtual key with or without user verification and watch the signature counter change. Run every ceremony there first, then test on a real iPhone, Android phone, Windows PC and Mac.

Planning passkeys for your own product? Tell us about your login flow and we will map the work with you.

Attestation, user verification and the signature counter

These three settings confuse more teams than any other part of a passkey implementation. Here is what each one does and the value most products should pick.

Attestation: none or direct

Attestation is a signed statement about the authenticator model. The spec offers none, indirect, direct and enterprise, and none is the default. With none, you do not care which device made the passkey.

Choose direct only when policy demands proof of the hardware, such as approved security keys for staff. Direct asks for a verifiable statement, but the spec gives no promise you will get one. You also need trusted metadata, usually the FIDO Metadata Service, to make sense of it.

User verification: required or preferred

User verification (UV) means the device checked a fingerprint, face or PIN. User presence (UP) only means someone tapped or clicked. You can ask for required, preferred or discouraged. Browsers use preferred when you pass nothing.

The spec says to demand the UV flag only when you set userVerification to required. Pick required when the passkey is the only factor for a sensitive account. Keep preferred when you must support security keys without a PIN.

The signature counter

The counter was meant to catch cloned keys. The spec now says authenticators that skip the counter keep it at zero. Synced passkeys often do this, because several devices share one key.

So do not reject a login only because the counter stayed at zero. If either value is above zero and the new one is not higher, the spec calls that a signal, not proof. Log it and add it to your risk score.

Pro tip: Watch the BS (backup state) flag over time. A device-bound credential that suddenly reports a backup may point to a change you want to review.

A real example: one login in front of five products

We are building a member portal for HUSK, a corporate wellness platform. The portal puts one sign-up and one login in front of five HUSK products, on a React frontend and a Node backend. HUSK does not use passkeys today, and we do not claim it does.

The project still shows a lesson that applies to any passkey plan. When one identity layer serves many products, the RP ID choice decides everything. Put every product under one parent domain and a single passkey works across all of them. Spread them across separate domains and you need related origins, or users end up with one passkey per product.

So we settle the domain map before writing any login code. It costs an hour of planning and saves a forced re-enrollment later.

Launch checklist for your server

Run through this list before any passkey code reaches production:

  • Challenges come from a secure random source on the server and hold at least 16 bytes, as the spec advises.
  • Each challenge lives in the server session, works once and expires a few minutes after you issue it.
  • The origin check uses an exact list of allowed origins. No substring or “ends with” matching.
  • The RP ID stays the same across web, iOS and Android.
  • The server confirms a new credential ID does not belong to another account.
  • The user handle in each sign-in matches the credential’s owner.
  • Credential ID, public key, counter, transports, backup flags and AAGUID all reach the database.
  • Users can list, name and delete their passkeys from account settings.
  • Recovery has rate limits and sends an alert to the user.
  • Logs record failed ceremonies with the error name, so you can spot browser problems.

Common mistakes to avoid

  • Checking the origin with a loose match. A test like “contains example.com” lets example.com.attacker.net through. Compare against an exact list.
  • Reusing or skipping the challenge. A fixed challenge lets an attacker replay an old signed response.
  • Treating a zero counter as fraud. Many synced passkeys always report zero. Blocking them locks out honest users.
  • Asking for direct attestation by habit. It adds privacy prompts and work, and consumer apps rarely use the result.
  • Changing the RP ID after launch. Every existing passkey stops working the moment you do.
  • Putting an email address in the user handle. Use random bytes, because the handle can sit on the user’s device for years.
  • Forcing passkeys on day one. Offer them next to passwords first, then make them the default for new sign-ups.

When passwords still make sense

The passkeys vs passwords debate has an honest limit, and we tell clients so. Shared logins, such as one front-desk account used by several staff, fit badly. Each passkey belongs to one person’s device or password manager.

Some users run old phones or locked-down work laptops that cannot create passkeys. Your app may also call legacy systems that only accept a password. In these cases, keep the password as a fallback and protect it with rate limits and a second factor.

Regulated teams face another trade-off. Synced passkeys live in a consumer cloud account. If your auditors need keys that never leave approved hardware, plan for device-bound security keys and direct attestation for those staff.

Where passkeys fit in your wider security work

Passkeys fix the front door. They do not protect data at rest, secure your APIs or meet compliance rules alone. For those parts, read our guides on encryption and decryption, SaaS security practices and HIPAA and PCI DSS for software teams.

CodesClue is an AI-first software company with its engineering team in Ahmedabad and offices in India, the USA and Germany. We ship sign-in changes in short Agile sprints. A proof of concept on one login screen comes first, then an MVP behind a feature flag, then a full rollout.

Our software security and governance team reviews authentication design and access rules. For data protection beyond the login, see our data security services. Our DevSecOps consulting team can add passkey tests and checks to your build pipeline. You can also hire DevSecOps engineers. Once we agree the scope for your passkey work and you approve your engineer, development starts within 48 hours.

Pro tip: Ship passkeys to your own staff accounts first. Your team finds the rough edges on real devices before customers ever see the prompt.

Passkeys vs passwords: what to do next

The passkeys vs passwords choice is no longer either-or. Add passkeys next to passwords, follow the spec’s server checks and build recovery before you remove anything. A careful WebAuthn implementation gives your users faster sign-in and gives phishing pages nothing to steal.

Want a second pair of eyes on your login flow? Contact CodesClue and share your current setup. We will point out the gaps and plan a passkey rollout that fits your users.

FAQs

Can an attacker log in if they breach my database and steal my public key?

No. Public keys are completely useless on their own. Authentication requires a unique signature created by the matching private key, which never leaves the user’s physical device.

What makes a passkey different from a standard password manager?

A password manager simply memorises and fills in old-fashioned, vulnerable passwords. A passkey replaces passwords entirely with an unshareable, encrypted cryptographic key pair.

Why does the guide say a substring check on the origin completely breaks security?

If your server code checks for yourdomain.com using a substring match, an attacker can use fake-yourdomain.com. Only an exact match blocks phishing sites entirely.

Why does turning on residentKey: 'required' matter for the user experience?

This specific code setting forces the device to store the user identity inside the credential. It allows users to log in with a single tap via conditional autofill without typing their username first.

Why should I use an open-source library instead of writing the verification code myself?

Parsing cryptographic attestation formats involves complex, high-risk edge cases. Standard maintained libraries ensure your backend code stays updated against hidden validation vulnerabilities.

Do passkeys work if a user loses their phone?

Yes, as long as they registered a synced passkey through iCloud Keychain, Google Password Manager, or a similar service, or if they have a second device registered. This is why requiring at least two passkeys before disabling passwords matters.

Can I run passkeys and passwords side by side?

Yes, and most production rollouts do exactly this for months. Passkeys can sit next to your existing password flow without any disruption to current users.

Is WebAuthn supported across all major browsers?

Yes. Chrome, Safari, Firefox, and Edge all support the WebAuthn API, and adoption across Apple, Google, and Microsoft platforms means most users already have a passkey-capable device.

  • Security and compliance

Written by Ketan Patel for CodesClue, a software development company with teams in India, the USA and Germany that designs, builds and supports web, mobile and AI products. About CodesClue

Want this done for your product?

Tell us what you are planning. An engineer replies within one business day with honest next steps, and we sign an NDA before any engagement.

  1. Answer two quick questions and tell us about the project.
  2. We read it and reply with questions or a plan.
  3. You get a written estimate with milestones before anything is signed.
See what we have built

    Build together with CodesClue