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 { authClient } from "@/lib/auth-client"
import { useListPasskeys } from "@better-auth-ui/react/plugins/passkey"

const { data: passkeys } = useListPasskeys(authClient)

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

useListPasskeys requires the Better Auth passkey plugin. Import your configured authClient. It already carries the plugin methods from createAuthClient.

Options factory

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

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

Invalidation

import { listPasskeysOptions } from "@better-auth-ui/core/plugins/passkey"

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

Params

Prop

Type

Last updated on

On this page