BETTER-AUTH. UI
Queries

useListPasskeys

Retrieve the passkeys registered for the current user.

Keyed per-user; waits for the active session before firing.

The Better Auth client method is authClient.passkey.listUserPasskeys, while the corresponding server endpoint is auth.api.listPasskeys. The names diverge in Better Auth itself — this is not a typo. We expose a single unified listPasskeys API on top (hooks, options, helpers all drop the redundant User infix).

Usage

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

const { authClient } = useAuth()
const { data: passkeys } = useListPasskeys(
  authClient as PasskeyAuthClient
)

// With React Query options
const { data: passkeys } = useListPasskeys(
  authClient as PasskeyAuthClient,
  { refetchOnMount: false }
)

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

Options factory

import { listPasskeysOptions } from "@better-auth-ui/react"
import { useQuery } from "@tanstack/react-query"

const { data: passkeys } = useQuery(
  listPasskeysOptions(authClient, userId)
)

Invalidation

import { listPasskeysOptions } from "@better-auth-ui/react"

queryClient.invalidateQueries({
  queryKey: listPasskeysOptions(authClient, userId).queryKey
})

Params

Prop

Type

Last updated on

On this page