BETTER-AUTH. UI
Queries

useListDeviceSessions

List device sessions for multi-session account switching.

Requires the Better Auth multi-session plugin on your client/server setup. Import the helper from @better-auth-ui/core/plugins/multi-session. The endpoint succeeds only when your Better Auth client exposes multi-session methods.

Usage

import { useListDeviceSessions } from "@better-auth-ui/solid/plugins/multi-session"

const deviceSessions = useListDeviceSessions(authClient)

Options factory and loader helpers

import {
  ensureListDeviceSessions,
  fetchListDeviceSessions,
  listDeviceSessionsOptions,
  prefetchListDeviceSessions
} from "@better-auth-ui/core/plugins/multi-session"

const options = listDeviceSessionsOptions(authClient, userId)
await ensureListDeviceSessions(queryClient, authClient, userId)
await prefetchListDeviceSessions(queryClient, authClient, userId)
const sessions = await fetchListDeviceSessions(queryClient, 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

On this page