import { DataTag, QueryClient } from '@tanstack/react-query'; import { APIError } from 'better-auth'; import { AuthServer } from '../../../lib/auth-server'; export type SessionData = Awaited>; export type Session = NonNullable>; export type SessionParams = Parameters[0]; /** * Query options factory for the current session on the server. * * Uses the same query key as the client-side `sessionOptions` so that data * fetched during SSR hydrates seamlessly into the client's React Query cache. * * @param auth - The Better Auth server instance. * @param params - Parameters forwarded to `auth.api.getSession` (typically * includes request `headers` for cookie-based session resolution). */ export declare function sessionOptions(auth: TAuth, params: SessionParams): (import('@tanstack/query-core').OmitKeyof>, APIError, Awaited>, readonly ["auth", "getSession"]>, "queryFn"> & { queryFn?: import('@tanstack/query-core').QueryFunction>, readonly ["auth", "getSession"], never> | undefined; } & { queryKey: readonly ["auth", "getSession"] & { [dataTagSymbol]: Awaited>; [dataTagErrorSymbol]: APIError; }; }) & { queryKey: DataTag>, APIError>; }; /** * Get the current session from the query cache, calling `fetchSession` under * the hood if no cached entry exists. Resolves with the session data, making * it suitable for reading the value directly in a server component. * * @param queryClient - The React Query client used for SSR hydration. * @param auth - The Better Auth server instance. * @param params - Parameters forwarded to `auth.api.getSession`. */ export declare const ensureSession: (queryClient: QueryClient, auth: TAuth, params: SessionParams) => Promise>>; /** * Prefetch the current session into the query cache. Behaves like * `fetchSession`, but does not throw on error and does not return the data — * use this when you only need the value to be available after hydration. * * @param queryClient - The React Query client used for SSR hydration. * @param auth - The Better Auth server instance. * @param params - Parameters forwarded to `auth.api.getSession`. */ export declare const prefetchSession: (queryClient: QueryClient, auth: TAuth, params: SessionParams) => Promise; /** * Fetch and cache the current session, 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 used for SSR hydration. * @param auth - The Better Auth server instance. * @param params - Parameters forwarded to `auth.api.getSession`. */ export declare const fetchSession: (queryClient: QueryClient, auth: TAuth, params: SessionParams) => Promise>>;