BETTER-AUTH. UI
Mutations

useAddPasskey

Register a new passkey for the current user.

Prompts the WebAuthn ceremony then refetches the passkey list on success.

Usage

import {
  type PasskeyAuthClient,
  useAddPasskey,
  useAuth
} from "@better-auth-ui/react"

const { authClient } = useAuth()
const { mutate: addPasskey, isPending } = useAddPasskey(
  authClient as PasskeyAuthClient
)

addPasskey({ name: "MacBook Pro" })

useAddPasskey requires the Better Auth passkey plugin. Cast authClient to PasskeyAuthClient so TypeScript picks up the plugin-extended method signature.

Options factory

import { addPasskeyOptions } from "@better-auth-ui/react"
import { useMutation } from "@tanstack/react-query"

const { mutate } = useMutation(addPasskeyOptions(authClient))

Params

Prop

Type

Last updated on

On this page