Queries
Solid Query factories and auth read helpers.
Solid query APIs provide options and hooks for Better Auth read endpoints. They use shared cache keys from @better-auth-ui/core.
Each supported query provides an options factory. Queries that are safe for components also provide a use* hook.
Session and user queries also provide ensure*, prefetch*, and fetch* helpers for route loaders.
import { useSession } from "@better-auth-ui/solid"
import { sessionOptions } from "@better-auth-ui/core"
const sessionQuery = sessionOptions(authClient)
const session = useSession(authClient, () => ({ enabled: !import.meta.env.SSR }))Invalidation
All keys start with ["auth", ...]. Queries for one user use the ["auth", "user", userId, ...] prefix.
Invalidate a prefix to control the related cache entries. Use authQueryKeys from @better-auth-ui/core to create consistent keys:
import { authQueryKeys } from "@better-auth-ui/core"
queryClient.invalidateQueries({ queryKey: authQueryKeys.all })
queryClient.invalidateQueries({ queryKey: authQueryKeys.user(userId) })
queryClient.invalidateQueries({ queryKey: authQueryKeys.session })Per-user queries
Settings queries use a separate cache key for each user. They wait for the session before they start.
Solid hooks remain disabled until their required user values resolve. Consumer enabled controls still apply.
This design removes stale data after sign-out. It also isolates data after an account switch.
Escape hatch
For read-style endpoints without a purpose-built Solid helper, use useAuthQuery in components or authQueryOptions where Solid Query takes an options object.
import { useAuthQuery } from "@better-auth-ui/solid"
const result = useAuthQuery(
authClient.magicLink.list,
["auth", "magicLink", "list"],
{ query: { limit: 20 } }
)Available queries
Auth
useSession
The current authenticated session.
useUser
The current authenticated user, derived from the session cache.
useAuthenticate
Session query plus Solid-side redirect when unauthenticated.
usePublicOAuthClient
Public metadata for the application requesting OAuth authorization.
Settings
useListAccounts
The current user's linked social accounts.
useAccountInfo
Provider-specific info for a linked account.
useListSessions
Active sessions for the current user.
useListDeviceSessions
Device sessions for multi-session account switching.
useListPasskeys
Passkeys registered for the current user.
useListApiKeys
API keys for the current user when the API key plugin is installed.
useGetApiKey
One API key selected by ID.
Organization
Last updated on