Queries
useListSessions
Retrieve the active sessions (devices) for the current user.
Keyed per-user; waits for the active session before firing.
Usage
import { useAuth, useListSessions } from "@better-auth-ui/react"
const { authClient } = useAuth()
const { data: sessions } = useListSessions(authClient)
// With React Query options
const { data: sessions } = useListSessions(authClient, { refetchOnMount: false })Options factory
import { listSessionsOptions } from "@better-auth-ui/react"
import { useQuery } from "@tanstack/react-query"
const { data: sessions } = useQuery(listSessionsOptions(authClient, userId))Invalidation
import { listSessionsOptions } from "@better-auth-ui/react"
queryClient.invalidateQueries({
queryKey: listSessionsOptions(authClient, userId).queryKey
})Params
Prop
Type
Last updated on