Queries
useListOAuthConsents
List the OAuth applications the current user has authorized.
Requires oauthProviderClient() from @better-auth/oauth-provider/client.
Returns the raw consent records Better Auth stores for the signed-in user. One OAuth client can have several records, so pair this with groupOAuthConsents from @better-auth-ui/core/plugins before rendering.
Usage
import { groupOAuthConsents } from "@better-auth-ui/core/plugins"
import { useAuth, useListOAuthConsents } from "@better-auth-ui/react"
const { authClient } = useAuth()
const { data: consents } = useListOAuthConsents(authClient)
const applications = groupOAuthConsents(consents)The query key is scoped to the signed-in user, so one account's authorized applications never surface in another account's view.
Client options factory and router-loader helpers
import {
ensureListOAuthConsents,
fetchListOAuthConsents,
listOAuthConsentsOptions,
prefetchListOAuthConsents
} from "@better-auth-ui/react"
const options = listOAuthConsentsOptions(authClient, userId)
await ensureListOAuthConsents(queryClient, authClient, userId)
await prefetchListOAuthConsents(queryClient, authClient, userId)
const consents = await fetchListOAuthConsents(queryClient, authClient, userId)Invalidation
import { oauthProviderQueryKeys } from "@better-auth-ui/core/plugins"
queryClient.invalidateQueries({
queryKey: oauthProviderQueryKeys.consents(userId)
})useDeleteOAuthConsent already awaits this invalidation, so a partially failed removal still ends up reflecting the server's state.
Params
Prop
Type
Last updated on