Skip to main content

Function: getCsrfToken()

function getCsrfToken(options?): Promise<string | null>

Fetches the CSRF token used by Auth.js form submissions.

Parameters

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

Returns

Promise<string | null>

A string token or null if the request fails.

Examples

const csrf = await getCsrfToken()
const csrf = await getCsrfToken({ basePath: '/auth' })