Skip to main content

Function: getSession()

function getSession<T>(options?): Promise<T | null>

Retrieves the current Auth.js session object, if one exists.

Type Parameters

Type ParameterDefault type
T extends SessionSession

Parameters

ParameterTypeDescription
options?ClientOptionsOverrides for base path, headers, or a custom fetch implementation.

Returns

Promise<T | null>

The active session payload or null when the user is not authenticated.

Examples

const session = await getSession()
const session = await getSession({ headers: { cookie: context.cookie } })