Function: getSession()
function getSession<T>(options?): Promise<T | null>
Retrieves the current Auth.js session object, if one exists.
Type Parameters
Type Parameter | Default type |
---|---|
T extends Session | Session |
Parameters
Parameter | Type | Description |
---|---|---|
options ? | ClientOptions | Overrides 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 } })