Skip to main content
@capgo/capacitor-passkey Auth & Security Open source

Passkey Capacitor plugin

Keep browser-style WebAuthn code in Capacitor while native passkey calls and host patching are handled for you

Install

bun add @capgo/capacitor-passkey bunx cap sync
npm, pnpm or yarn
  • npm install @capgo/capacitor-passkey
  • pnpm add @capgo/capacitor-passkey
  • yarn add @capgo/capacitor-passkey

Guide

How to use Passkey in Capacitor

Using @capgo/capacitor-passkey

Keep your browser-style WebAuthn code in a Capacitor app while the plugin handles native passkey calls and native host patching.

Browser-style API

@capgo/capacitor-passkey keeps the same WebAuthn flow you already use on the web:

await navigator.credentials.create({ publicKey: registrationOptions });
await navigator.credentials.get({ publicKey: requestOptions });

On native builds, the plugin installs a shim for navigator.credentials.create() and navigator.credentials.get(), forwards the request to iOS and Android passkey APIs, and returns browser-like credential objects to your app.

Install and sync native projects

bun add @capgo/capacitor-passkey
bunx cap sync

Configure the host app once

Add the plugin config in capacitor.config.ts or capacitor.config.json:

import type { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  appId: 'app.capgo.passkey.example',
  appName: 'My App',
  webDir: 'dist',
  plugins: {
    CapacitorPasskey: {
      origin: 'https://signin.example.com',
      autoShim: true,
      domains: ['signin.example.com'],
    },
  },
};

export default config;

What the plugin config does

The config is read from plugins.CapacitorPasskey in capacitor.config.*.

  • origin: primary HTTPS relying-party origin used by the shim and direct API
  • domains: extra relying-party hostnames to patch into native config during sync
  • autoShim: defaults to true and controls the native cap sync auto-configuration hook

Run sync again after changing the config:

bunx cap sync

Install the shim during bootstrap

Import the plugin from the standard package entrypoint, then install the shim during app bootstrap:

import { CapacitorPasskey } from '@capgo/capacitor-passkey';

await CapacitorPasskey.autoShimWebAuthn();

After that, your existing browser-style passkey code can stay the same.

If you need to force the shim or override the configured origin at runtime, call:

import { CapacitorPasskey } from '@capgo/capacitor-passkey';

CapacitorPasskey.shimWebAuthn({
  origin: 'https://signin.example.com',
});

Keep your normal WebAuthn flow

const credential = await navigator.credentials.create({
  publicKey: registrationOptions,
});

const assertion = await navigator.credentials.get({
  publicKey: requestOptions,
});

What sync patches for you

During bunx cap sync, the plugin updates the generated native host projects:

  • iOS: associated domains entitlements and Xcode entitlements wiring when needed
  • Android: asset_statements metadata and the generated resource used by the manifest

Native setup still needs website trust files

The plugin reduces app-side work, but passkeys still depend on the website trust files for your relying-party domain. You still need to host:

  • https://your-domain/.well-known/apple-app-site-association
  • https://your-domain/.well-known/assetlinks.json

The plugin can patch the generated native projects during sync, but it cannot create or host those website trust files for you.

Other public methods

The public plugin API also exposes the direct helpers defined in src/definitions.ts:

  • await CapacitorPasskey.getConfiguration() returns the resolved origin, domains, autoShim, and current platform.
  • await CapacitorPasskey.createCredential(...) registers a passkey from a JSON-safe WebAuthn payload.
  • await CapacitorPasskey.getCredential(...) authenticates with an existing passkey from a JSON-safe WebAuthn payload.
  • await CapacitorPasskey.isSupported() reports whether the current runtime supports passkeys.
  • await CapacitorPasskey.getPluginVersion() returns the current native implementation version marker.

Platform guides

Important iOS note

On iOS 17.4 and newer, the plugin uses the browser-style client-data API so the configured HTTPS origin is reflected in clientDataJSON.

Important Android caveat

Android Credential Manager can share the same relying party and passkeys as your website when Digital Asset Links are configured, but the native assertion origin is not identical to a browser origin. If your backend strictly validates clientDataJSON.origin, make sure it accepts the Android app origin alongside your website origin.

Full Reference

Keep going from Using @capgo/capacitor-passkey

If you are using Using @capgo/capacitor-passkey to plan authentication and account flows, connect it with @capgo/capacitor-passkey for the implementation detail in @capgo/capacitor-passkey, Getting Started for the implementation detail in Getting Started, @capgo/capacitor-social-login for the implementation detail in @capgo/capacitor-social-login, @capgo/capacitor-native-biometric for the implementation detail in @capgo/capacitor-native-biometric, and Two-factor authentication for the implementation detail in Two-factor authentication.

FAQ

Passkey plugin FAQ

How do I install the Passkey plugin in a Capacitor app?

Run "bun add @capgo/capacitor-passkey" (or "npm install @capgo/capacitor-passkey"), then run "bunx cap sync" so the iOS and Android projects pick up the native code. Import it from "@capgo/capacitor-passkey" in your app code.

Does @capgo/capacitor-passkey work with React, Vue and Angular?

Yes. Passkey is a Capacitor package, so it works with any web framework that runs inside Capacitor, including Ionic, React, Vue, Angular, Svelte and plain JavaScript.

Which Capacitor version does @capgo/capacitor-passkey support?

Capgo plugins follow Capacitor's major version: use the plugin major version that matches your Capacitor major version (for example plugin v8 with Capacitor 8). The compatibility table in the GitHub README lists the maintained versions.

Is @capgo/capacitor-passkey free and open source?

Yes. The source code is public on GitHub at https://github.com/Cap-go/capacitor-passkey/ and the package is free to install from npm. Bug reports and pull requests are welcome.

Can I update code that uses Passkey without an App Store review?

Installing or upgrading the plugin changes native code, so it needs a new store build. After that, JavaScript, HTML and CSS changes that call the plugin can ship instantly with Capgo live updates.

Ship Passkey changes without waiting for app review

Once the plugin is in your store build, Capgo live updates push your JavaScript, HTML and CSS changes to users in minutes.

Start with Capgo