Skip to main content

Function: getServerSession()

function getServerSession(input?): Promise<Session | null>

Resolves the current Auth.js session by invoking the session route directly.

Parameters

ParameterTypeDescription
input?anyRequest or headers used to infer cookies; defaults to an empty header set.

Returns

Promise<Session | null>

The active Auth.js session or null when no session is available.

Examples

const session = await getServerSession(request)
const session = await getServerSession(new Request(url, { headers: myHeaders }))