BETTER-AUTH. UI
Queries

useAccountInfo

Retrieve provider-specific info for a linked account.

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

Usage

import { useAccountInfo, useAuth } from "@better-auth-ui/react"

const { authClient } = useAuth()
const { data: accountInfo } = useAccountInfo(authClient, {
  query: { accountId: "acc_123" }
})

// With React Query options in the same object
const { data: accountInfo } = useAccountInfo(authClient, {
  query: { accountId: "acc_123" },
  staleTime: 60_000
})

Options factory

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

const { data: accountInfo } = useQuery(
  accountInfoOptions(authClient, userId, {
    query: { accountId: "acc_123" }
  })
)

Invalidation

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

queryClient.invalidateQueries({
  queryKey: accountInfoOptions(authClient, userId, {
    query: { accountId: "acc_123" }
  }).queryKey
})

Params

Prop

Type

Last updated on

On this page