Type session data returned by the client
Client session state
Better Auth · Type Alias
Session is Better Auth's inferred TypeScript type for the current session response. It includes both the session object and its associated user object, with configured extensions reflected in the type.
Session is an inferred TypeScript type exposed through Better Auth's $Infer property. It describes an object containing both the session record and the associated user object, with plugin-added fields included when applicable.
type Session = typeof authClient.$Infer.SessionAn inferred object type with session and user properties, reflecting configured and plugin-provided fields.
$Infer.user and session.import { createAuthClient } from "better-auth/client"
const authClient = createAuthClient()
export type Session = typeof authClient.$Infer.Session
const session: Session = await authClient.getSession()
console.log(session.session, session.user)This derives the client-side Session type from the configured Better Auth client and uses it for session data.
Client session state
Server request handling
Plugin-enabled applications
Use the client instance's $Infer property: type Session = typeof authClient.$Infer.Session. The resulting type contains both session and user properties.
Follow-up: How can server-side code infer the same type? Define the server auth instance and use typeof auth.$Infer.Session.
The user member represents the user object type, while session represents the session object type. This lets application code type both parts of the returned session data.
Follow-up: What should happen when a plugin adds fields? The inferred type should include plugin-provided extensions.
$Infer.Session over a handwritten interface?Plugins can extend the base User and Session types, and those additions are available through $Infer. Therefore, deriving the type from the configured client or server instance keeps it aligned with the active setup.
Follow-up: How would you avoid stale manually duplicated interfaces? Infer the type directly from the configured Better Auth instance.
User$InfercreateAuthClientSession ManagementgetSession