WebAuthn conditional mediation: connect passkey selection to the sign-in field
WebAuthn conditional mediation lets the browser offer available discoverable credentials when a user interacts with a sign-in field, without immediately covering the page with a modal. After the user selects a passkey, the browser and authenticator continue the ceremony. This is not automatic or server-side authentication: the relying party (RP) must still fully verify the WebAuthn assertion.
WebAuthn conditional mediation: connect passkey selection to the sign-in field
WebAuthn conditional mediation lets the browser offer available discoverable credentials when a user interacts with a sign-in field, without immediately covering the page with a modal. After the user selects a passkey, the browser and authenticator continue the ceremony. This is not automatic or server-side authentication: the relying party (RP) must still fully verify the WebAuthn assertion.
This guide covers mediation: "conditional" with navigator.credentials.get() under WebAuthn Level 3. Browser and platform support can change, so detect availability at runtime.
How it differs from a regular sign-in
A regular get() call may immediately show an authenticator picker. With conditional mediation, the RP can mark a username field for WebAuthn autofill and start a request; the browser presents credentials when available and the user interacts with the field and suggestion. It does not remove the need for visible user action.
The flow uses discoverable credentials, unlike a username-first flow where the server supplies a specific credential ID. You can also offer password or other sign-in methods, but design fallback so it does not weaken existing authentication.
Implementation sequence
Check `PublicKeyCredential.isConditionalMediationAvailable()` or a supported client capability. If unavailable, show the usual explicit passkey sign-in button.
Create fresh request options on the server, including a challenge and RP ID, and set the appropriate WebAuthn `autocomplete` token on the username field.
Start `navigator.credentials.get({ publicKey, mediation: "conditional" })`. Manage the pending request while the user chooses a credential or another method; cancel stale requests on navigation or cancellation, for example with `AbortController`.
Send the assertion to the server and verify the credential, signature, challenge, origin, RP ID hash, account mapping, required UP/UV flags, and state.
Treat `NotAllowedError`, cancellation, timeout, or no selection as a safe sign-in outcome and offer another method. Do not create a session before authentication succeeds.
Verification checklist
Can a user choose a passkey from the field, and does the existing sign-in work when conditional mediation is unavailable?
Do cancellation, closing the browser, or multiple tabs avoid reusing an old challenge?
Are users given useful guidance and a fallback when no discoverable credential is available?
Does the server reject an invalid origin, challenge, or signature?
Does the flow avoid unnecessarily exposing usernames or whether an account is registered?
References
W3C, [Web Authentication Level 3: Conditional Mediation](https://www.w3.org/TR/webauthn-3/#dom-publickeycredentialrequestoptions-mediation)
W3C, [Web Authentication Level 3: Conditional mediation availability](https://www.w3.org/TR/webauthn-3/#dom-publickeycredential-isconditionalmediationavailable)