Function: getToken()
function getToken(input?, options?): Promise<Session | string | null>
Extracts the Auth.js session token derived from the provided context.
Parameters
| Parameter | Type | Description |
|---|---|---|
input? | any | Incoming request or headers whose cookies contain the Auth.js session token. |
options? | object | Set raw to true to receive the unparsed cookie value instead of a decoded JWT payload. |
options.raw? | boolean | - |
Returns
Promise<Session | string | null>
The decoded JWT, the raw cookie value, or null if no token could be resolved.
Examples
const token = await getToken(request, { raw: true })
const payload = await getToken(headers, { raw: false })