Skip to content

Passkey Authentication

Register and login with WebAuthn passkeys

Passkeys use the WebAuthn standard for passwordless authentication. Users authenticate with biometrics (Face ID, Touch ID, fingerprint) or a hardware security key.

Configure RP ID (optional)

Set rpId on the connector if you need a custom relying party identifier (defaults to the current hostname):

zeroDevWallet({
  projectId: process.env.NEXT_PUBLIC_ZERODEV_PROJECT_ID!,
  chains: [sepolia],
  rpId: "example.com",
});

Hooks

Example

import { useAccount, useDisconnect } from 'wagmi'
import { useRegisterPasskey, useLoginPasskey } from '@zerodev/wallet-react'
 
function PasskeyAuth() {
  const { address, isConnected } = useAccount()
  const { disconnectAsync } = useDisconnect()
  const registerPasskey = useRegisterPasskey()
  const loginPasskey = useLoginPasskey()
 
  if (isConnected) {
    return (
      <div>
        <p>Connected: {address}</p>
        <button onClick={() => disconnectAsync()}>Logout</button>
      </div>
    )
  }
 
  return (
    <div>
      <button
        onClick={() => registerPasskey.mutateAsync()}
        disabled={registerPasskey.isPending}
      >
        {registerPasskey.isPending ? 'Registering...' : 'Create Wallet'}
      </button>
 
      <button
        onClick={() => loginPasskey.mutateAsync()}
        disabled={loginPasskey.isPending}
      >
        {loginPasskey.isPending ? 'Logging in...' : 'Login'}
      </button>
 
      {registerPasskey.isError && (
        <p>Registration error: {registerPasskey.error.message}</p>
      )}
      {loginPasskey.isError && (
        <p>Login error: {loginPasskey.error.message}</p>
      )}
    </div>
  )
}

How it works

  1. Register: useRegisterPasskey triggers the browser's WebAuthn prompt. The user creates a passkey stored on their device. A new wallet is created and linked to the passkey.

  2. Login: useLoginPasskey triggers the WebAuthn prompt. The user selects their existing passkey. The SDK authenticates and creates a session.

After either flow, the Wagmi connector is connected and the user's address is available via useAccount.

Notes

  • No email is required for passkey auth — the passkey itself is the credential
  • Passkeys are supported in all major browsers (Chrome, Safari, Firefox, Edge)
  • Passkeys can sync across devices via iCloud Keychain, Google Password Manager, etc.