メインコンテンツまでスキップ

Function: detectPasskeyCapability()

detectPasskeyCapability(): Promise<PasskeyCapability>

Checks whether this browser can use a passkey on this device, without any prompt or user gesture. It needs no sign-in and no createUpbond(), so it can run before login(), even on page load. Call it in the browser only: on a server there is no WebAuthn and the answer is 'unavailable'.

  • 'unavailable': WebAuthn is missing, or the device reports no usable platform authenticator. It cannot tell which: typically no screen lock (passcode, PIN or biometrics) is set up, or an in-app browser blocks it.
  • 'capable': nothing ruled a passkey out. Creating a wallet can still fail (the user cancels, no PRF support, the passkey provider refuses). Inconclusive checks, including no answer within 1500 ms, also read 'capable'.

Before sign-in you do not know whether the visitor already owns a wallet, so show guidance rather than disabling your sign-in or wallet buttons.

Returns​

Promise<PasskeyCapability>

Example​

if ((await detectPasskeyCapability()) === 'unavailable') {
showNotice('Set up a screen lock on this device, or open this page in your browser.');
}