Skip to content

Get Login Methods

Read the authenticated user's login methods

Use useAuthenticators after the wallet is connected to read the login methods linked to the current user, such as email contacts, OAuth identities, and passkeys.

Import

import { useAuthenticators } from '@zerodev/wallet-react'

Usage

import { useAuthenticators } from '@zerodev/wallet-react'
import { useAccount } from 'wagmi'
 
function UserProfile() {
  const { isConnected } = useAccount()
  const { data, isLoading } = useAuthenticators({
    query: {
      enabled: isConnected,
    },
  })
 
  if (!isConnected) return null
 
  if (isLoading) return <p>Loading user...</p>
 
  const email = data?.emailContacts?.[0]?.email
 
  return <p>Email: {email ?? 'Not available'}</p>
}

Parameters

import { type UseQueryOptions } from '@tanstack/react-query'
import { type Config } from 'wagmi'

config

Config | undefined

Optional Wagmi config. If omitted, the hook uses the nearest Wagmi config from context.

query

Omit<UseQueryOptions<GetAuthenticatorsReturnType>, 'queryKey' | 'queryFn'> | undefined

Optional TanStack Query options. Use this to control when the request runs, retry behavior, stale time, and other query settings.

Return Types

TanStack Query docs

data

GetAuthenticatorsReturnType | undefined

The authenticated user's linked authenticators, grouped by type. The query requires an active ZeroDev wallet session.

oauths

OAuthAuthenticator[] | null

OAuth identities linked to the user.

passkeys

PasskeyAuthenticator[] | null

Passkey authenticators registered for the user.

emailContacts

EmailContact[] | null

Email contacts linked to the user. Use emailContacts?.[0]?.email when you need the user's email address after Email OTP, Magic Link, or Google OAuth.

apiKeys

ApiKeyAuthenticator[] | null

API-key authenticators associated with the user.

error

Error | null

  • The error object for the query, if an error was thrown.
  • Defaults to null

isError / isPending / isSuccess

boolean

Boolean variables derived from status.

isFetched

boolean

Will be true if the query has been fetched.

isLoading

boolean

  • Is true whenever the first fetch for a query is in-flight
  • Is the same as isFetching && isPending

status

'error' | 'pending' | 'success'

  • pending if there's no cached data and no query attempt was finished yet.
  • error if the query attempt resulted in an error. The corresponding error property has the error received from the attempted fetch
  • success if the query has received a response with no errors and is ready to display its data. The corresponding data property on the query is the data received from the successful fetch or if the query's enabled property is set to false and has not been fetched yet data is the first initialData supplied to the query on initialization.

refetch

(options: { cancelRefetch?: boolean | undefined; throwOnError?: boolean | undefined }) => Promise<UseQueryResult>

  • A function to manually refetch the query.
  • throwOnError
    • When set to true, an error will be thrown if the query fails.
    • When set to false, an error will be logged if the query fails.
  • cancelRefetch
    • When set to true, a currently running request will be cancelled before a new request is made.
    • When set to false, no refetch will be made if there is already a request running.
    • Defaults to true