Skip to content

Testing for passkey support

Most devices and browsers now support passkeys, albeit with a few quirks. Nevertheless, don’t assume support is universal.

Before prompting the user to register or authenticate with a passkey you should call isPasskeySupport().

frontend/register.ts
import { isPasskeySupport } from "@passlock/client";
if (!isPasskeySupport()) {
throw new Error("Bad news...")
}

Alternatively test for the PasskeyUnsupported error:

frontend/register.ts
import {
registerPasskey,
isRegistrationSuccess,
isPasskeyUnsupported
} from "@passlock/client";
const result = await registerPasskey({ ... })
if (isRegistrationSuccess(result)) {
// happy days
} else if (isPasskeyUnsupported(result)) {
// no passkey support on this device
} else { ... }