import { DataTag, QueryClient } from '@tanstack/react-query'; import { BetterFetchError } from 'better-auth/react'; import { InferData, MultiSessionAuthClient } from '../../lib/auth-client'; export type ListDeviceSessionsData = InferData; export type ListDeviceSession = NonNullable>[number]; export type ListDeviceSessionsParams = Parameters[0]; export type ListDeviceSessionsOptions = Omit>, "queryKey" | "queryFn">; /** * Query options factory for the current user's device sessions. * * @param authClient - The Better Auth client with the multi-session plugin. * @param userId - The current signed-in user's ID. Used for cache partitioning. * @param params - Parameters forwarded to `authClient.multiSession.listDeviceSessions`. */ export declare function listDeviceSessionsOptions(authClient: TAuthClient, userId: string | undefined, params?: ListDeviceSessionsParams): (import('@tanstack/query-core').OmitKeyof, BetterFetchError, InferData, readonly ["auth", "user", string | undefined, "multiSession", "list", Record | null]>, "queryFn"> & { queryFn?: import('@tanstack/query-core').QueryFunction, readonly ["auth", "user", string | undefined, "multiSession", "list", Record | null], never> | undefined; } & { queryKey: readonly ["auth", "user", string | undefined, "multiSession", "list", Record | null] & { [dataTagSymbol]: InferData; [dataTagErrorSymbol]: BetterFetchError; }; }) & { queryKey: DataTag | null], InferData, BetterFetchError>; }; /** * Get the current user's device sessions from the query cache, calling * `fetchListDeviceSessions` under the hood if no cached entry exists. * Resolves with the device session list, making it ideal for loaders or * `beforeLoad` guards. * * @param queryClient - The React Query client. * @param authClient - The Better Auth client with the multi-session plugin. * @param userId - The signed-in user's ID, used for cache partitioning. * @param params - Parameters forwarded to `authClient.multiSession.listDeviceSessions`. */ export declare const ensureListDeviceSessions: (queryClient: QueryClient, authClient: TAuthClient, userId: string, params?: ListDeviceSessionsParams) => Promise>; /** * Prefetch the current user's device sessions into the query cache. Behaves * like `fetchListDeviceSessions`, but does not throw on error and does not * return the data — use this to warm the cache without blocking navigation. * * @param queryClient - The React Query client. * @param authClient - The Better Auth client with the multi-session plugin. * @param userId - The signed-in user's ID, used for cache partitioning. * @param params - Parameters forwarded to `authClient.multiSession.listDeviceSessions`. */ export declare const prefetchListDeviceSessions: (queryClient: QueryClient, authClient: TAuthClient, userId: string, params?: ListDeviceSessionsParams) => Promise; /** * Fetch and cache the current user's device sessions, resolving with the * data or throwing on error. If a cached entry exists and is neither * invalidated nor older than `staleTime`, the cached value is returned * without a network call; otherwise the latest data is fetched. * * @param queryClient - The React Query client. * @param authClient - The Better Auth client with the multi-session plugin. * @param userId - The signed-in user's ID, used for cache partitioning. * @param params - Parameters forwarded to `authClient.multiSession.listDeviceSessions`. */ export declare const fetchListDeviceSessions: (queryClient: QueryClient, authClient: TAuthClient, userId: string, params?: ListDeviceSessionsParams) => Promise>; export type UseListDeviceSessionsOptions = ListDeviceSessionsOptions & ListDeviceSessionsParams; /** * Subscribe to the current user's device sessions (multi-session account * switcher) via TanStack Query. * * Shares a query key with the server-side `listDeviceSessionsOptions`, so * SSR-hydrated data is reused from the cache without an immediate refetch. * The query is gated on a signed-in user; while the session is loading or * absent, the underlying `queryFn` is replaced with `skipToken`. * * @param authClient - The Better Auth client with the multi-session plugin. * @param options - `listDeviceSessions` params (`query`, `fetchOptions`) * merged with `useQuery` options (e.g. `enabled`, `staleTime`, `select`). * @param queryClient - Optional custom `QueryClient`. Defaults to the client * from the nearest `QueryClientProvider`. */ export declare function useListDeviceSessions(authClient: TAuthClient, options?: UseListDeviceSessionsOptions, queryClient?: QueryClient): import('@tanstack/react-query').UseQueryResult>, BetterFetchError>;