Queries
useListDeviceSessions
Retrieve the device sessions for the multi-session account switcher.
Powers the multi-session account switcher: each entry represents a session currently signed in on this device.
Keyed per-user. Waits for the active session before firing.
Usage
import { authClient } from "@/lib/auth-client"
import { useListDeviceSessions } from "@better-auth-ui/react/plugins/multi-session"
const { data: deviceSessions } = useListDeviceSessions(authClient)
// With React Query options
const { data: deviceSessions } = useListDeviceSessions(authClient, {
refetchOnMount: false
})useListDeviceSessions requires the Better Auth multiSession plugin. Import your configured authClient. It already carries the plugin methods from createAuthClient.
Options factory
import { listDeviceSessionsOptions } from "@better-auth-ui/core/plugins/multi-session"
import { useQuery } from "@tanstack/react-query"
const { data: deviceSessions } = useQuery(
listDeviceSessionsOptions(authClient, userId)
)Invalidation
import { listDeviceSessionsOptions } from "@better-auth-ui/core/plugins/multi-session"
queryClient.invalidateQueries({
queryKey: listDeviceSessionsOptions(authClient, userId).queryKey
})Params
Prop
Type
Last updated on