demo · v136

No-passkey fallback

The full sign-in flow in one page: call navigator.credentials.get({mediation: "immediate"}) on page load. If the browser knows of a passkey, the platform picker appears and the password form stays hidden. If not, the promise rejects NotAllowedError and the password form is revealed. One page, two UX paths.

Probing immediate mediation support.

flow log

the code

try {
  const cred = await navigator.credentials.get({
    mediation: "immediate",
    publicKey: { challenge, /* ... */ },
  });
  if (cred) signIn(cred);
} catch (e) {
  if (e.name === "NotAllowedError") {
    showPasswordForm();
  }
}

why this angle

The sibling concept shows the immediate prompt firing. This one shows the full fork — immediate prompt OR fallback form — which is what every real site has to wire up. The reject path is what makes the API safe to call on page load.

see also