Skip to content

Testing for browser 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/browser";
if (!isPasskeySupport()) {
throw new Error("Bad news...")
}

Alternatively test for the PasskeyUnsupportedError:

import { Passlock, isPasskeyUnsupportedError } from "@passlock/browser";
const passlock = new Passlock({ tenancyId });
const result = await passlock.registerPasskey(options)
if (result.success) {
// happy days
} else if (isPasskeyUnsupportedError(result.error)) {
// no passkey support on this device
} else {
console.error(result.error.message);
}
Choose your code style

Passlock also exposes capability checks for newer WebAuthn signal APIs. These are useful for features such as device-local passkey deletion, updates, and pruning:

frontend/signals.ts
import {
isPasskeyDeleteSupport,
isPasskeyPruningSupport,
isPasskeyUpdateSupport,
} from "@passlock/browser";
if (!isPasskeyDeleteSupport()) {
console.log("Local passkey deletion is unavailable on this device");
}
if (!isPasskeyUpdateSupport()) {
console.log("Local passkey updates are unavailable on this device");
}
if (!isPasskeyPruningSupport()) {
console.log("Local passkey pruning is unavailable on this device");
}