Skip to content
Migrating from NextAuth.js v4? Read our migration guide.

errors

AccessDenied

Thrown when the execution of the signIn callback fails or if it returns false.

Extends

Constructors

new AccessDenied(message, errorOptions)

new AccessDenied(message?, errorOptions?): AccessDenied
Parameters
ParameterType
message?string | ErrorOptions
errorOptions?ErrorOptions
Returns

AccessDenied

Inherited from

AuthError.constructor

Properties

cause?

optional cause: Record<string, unknown> & {
  err: Error;
};
Type declaration
err?
optional err: Error;
Inherited from

AuthError.cause

message

message: string;
Inherited from

AuthError.message

name

name: string;
Inherited from

AuthError.name

stack?

optional stack: string;
Inherited from

AuthError.stack

type

type: ErrorType;

The error type. Used to identify the error in the logs.

Inherited from

AuthError.type

prepareStackTrace()?

static optional prepareStackTrace: (err, stackTraces) => any;

Optional override for formatting stack traces

See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

Inherited from

AuthError.prepareStackTrace

stackTraceLimit

static stackTraceLimit: number;
Inherited from

AuthError.stackTraceLimit

type

static type: string = "AccessDenied";

Methods

captureStackTrace()

static captureStackTrace(targetObject, constructorOpt?): void

Create .stack property on a target object

Parameters
ParameterType
targetObjectobject
constructorOpt?Function
Returns

void

Inherited from

AuthError.captureStackTrace


AccountNotLinked

Thrown when an Email address is already associated with an account but the user is trying an account that is not linked to it.

For security reasons, Auth.js does not automatically link accounts to existing accounts if the user is not signed in.

Extends

Constructors

new AccountNotLinked(message, errorOptions)

new AccountNotLinked(message?, errorOptions?): AccountNotLinked
Parameters
ParameterType
message?string | ErrorOptions
errorOptions?ErrorOptions
Returns

AccountNotLinked

Inherited from

SignInError.constructor

Properties

cause?

optional cause: Record<string, unknown> & {
  err: Error;
};
Type declaration
err?
optional err: Error;
Inherited from

SignInError.cause

message

message: string;
Inherited from

SignInError.message

name

name: string;
Inherited from

SignInError.name

stack?

optional stack: string;
Inherited from

SignInError.stack

type

type: ErrorType;

The error type. Used to identify the error in the logs.

Inherited from

SignInError.type

kind

static kind: string = "signIn";
Inherited from

SignInError.kind

prepareStackTrace()?

static optional prepareStackTrace: (err, stackTraces) => any;

Optional override for formatting stack traces

See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

Inherited from

SignInError.prepareStackTrace

stackTraceLimit

static stackTraceLimit: number;
Inherited from

SignInError.stackTraceLimit

type

static type: string = "AccountNotLinked";

Methods

captureStackTrace()

static captureStackTrace(targetObject, constructorOpt?): void

Create .stack property on a target object

Parameters
ParameterType
targetObjectobject
constructorOpt?Function
Returns

void

Inherited from

SignInError.captureStackTrace


AdapterError

One of the database Adapter methods failed during execution.

💡

If debug: true is set, you can check out [auth][debug] in the logs to learn more about the failed adapter method execution.

Example

[auth][debug]: adapter_getUserByEmail
{ "args": [undefined] }

Extends

Constructors

new AdapterError(message, errorOptions)

new AdapterError(message?, errorOptions?): AdapterError
Parameters
ParameterType
message?string | ErrorOptions
errorOptions?ErrorOptions
Returns

AdapterError

Inherited from

AuthError.constructor

Properties

cause?

optional cause: Record<string, unknown> & {
  err: Error;
};
Type declaration
err?
optional err: Error;
Inherited from

AuthError.cause

message

message: string;
Inherited from

AuthError.message

name

name: string;
Inherited from

AuthError.name

stack?

optional stack: string;
Inherited from

AuthError.stack

type

type: ErrorType;

The error type. Used to identify the error in the logs.

Inherited from

AuthError.type

prepareStackTrace()?

static optional prepareStackTrace: (err, stackTraces) => any;

Optional override for formatting stack traces

See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

Inherited from

AuthError.prepareStackTrace

stackTraceLimit

static stackTraceLimit: number;
Inherited from

AuthError.stackTraceLimit

type

static type: string = "AdapterError";

Methods

captureStackTrace()

static captureStackTrace(targetObject, constructorOpt?): void

Create .stack property on a target object

Parameters
ParameterType
targetObjectobject
constructorOpt?Function
Returns

void

Inherited from

AuthError.captureStackTrace


AuthError

Base error class for all Auth.js errors. It’s optimized to be printed in the server logs in a nicely formatted way via the logger.error option.

Extends

Constructors

new AuthError(message, errorOptions)

new AuthError(message?, errorOptions?): AuthError
Parameters
ParameterType
message?string | ErrorOptions
errorOptions?ErrorOptions
Returns

AuthError

Overrides

Error.constructor

Properties

cause?

optional cause: Record<string, unknown> & {
  err: Error;
};
Type declaration
err?
optional err: Error;
Overrides

Error.cause

message

message: string;
Inherited from

Error.message

name

name: string;
Inherited from

Error.name

stack?

optional stack: string;
Inherited from

Error.stack

type

type: ErrorType;

The error type. Used to identify the error in the logs.

prepareStackTrace()?

static optional prepareStackTrace: (err, stackTraces) => any;

Optional override for formatting stack traces

See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

Inherited from

Error.prepareStackTrace

stackTraceLimit

static stackTraceLimit: number;
Inherited from

Error.stackTraceLimit

Methods

captureStackTrace()

static captureStackTrace(targetObject, constructorOpt?): void

Create .stack property on a target object

Parameters
ParameterType
targetObjectobject
constructorOpt?Function
Returns

void

Inherited from

Error.captureStackTrace


CallbackRouteError

This error occurs when the user cannot finish login. Depending on the provider type, this could have happened for multiple reasons.

💡

Check out [auth][details] in the logs to know which provider failed.

Example

[auth][details]: { "provider": "github" }

For an OAuth provider, possible causes are:

  • The user denied access to the application
  • There was an error parsing the OAuth Profile: Check out the provider’s profile or userinfo.request method to make sure it correctly fetches the user’s profile.
  • The signIn or jwt callback methods threw an uncaught error: Check the callback method implementations.

For an Email provider, possible causes are:

  • The provided email/token combination was invalid/missing: Check if the provider’s sendVerificationRequest method correctly sends the email.
  • The provided email/token combination has expired: Ask the user to log in again.
  • There was an error with the database: Check the database logs.

For a Credentials provider, possible causes are:

  • The authorize method threw an uncaught error: Check the provider’s authorize method.
  • The signIn or jwt callback methods threw an uncaught error: Check the callback method implementations.
💡

Check out [auth][cause] in the error message for more details. It will show the original stack trace.

Extends

Constructors

new CallbackRouteError(message, errorOptions)

new CallbackRouteError(message?, errorOptions?): CallbackRouteError
Parameters
ParameterType
message?string | ErrorOptions
errorOptions?ErrorOptions
Returns

CallbackRouteError

Inherited from

AuthError.constructor

Properties

cause?

optional cause: Record<string, unknown> & {
  err: Error;
};
Type declaration
err?
optional err: Error;
Inherited from

AuthError.cause

message

message: string;
Inherited from

AuthError.message

name

name: string;
Inherited from

AuthError.name

stack?

optional stack: string;
Inherited from

AuthError.stack

type

type: ErrorType;

The error type. Used to identify the error in the logs.

Inherited from

AuthError.type

prepareStackTrace()?

static optional prepareStackTrace: (err, stackTraces) => any;

Optional override for formatting stack traces

See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

Inherited from

AuthError.prepareStackTrace

stackTraceLimit

static stackTraceLimit: number;
Inherited from

AuthError.stackTraceLimit

type

static type: string = "CallbackRouteError";

Methods

captureStackTrace()

static captureStackTrace(targetObject, constructorOpt?): void

Create .stack property on a target object

Parameters
ParameterType
targetObjectobject
constructorOpt?Function
Returns

void

Inherited from

AuthError.captureStackTrace


CredentialsSignin

Can be thrown from the authorize callback of the Credentials provider. When an error occurs during the authorize callback, two things can happen:

  1. The user is redirected to the signin page, with error=CredentialsSignin&code=credentials in the URL. code is configurable.
  2. If you throw this error in a framework that handles form actions server-side, this error is thrown, instead of redirecting the user, so you’ll need to handle.

Extends

Constructors

new CredentialsSignin(message, errorOptions)

new CredentialsSignin(message?, errorOptions?): CredentialsSignin
Parameters
ParameterType
message?string | ErrorOptions
errorOptions?ErrorOptions
Returns

CredentialsSignin

Inherited from

SignInError.constructor

Properties

cause?

optional cause: Record<string, unknown> & {
  err: Error;
};
Type declaration
err?
optional err: Error;
Inherited from

SignInError.cause

code

code: string = "credentials";

The error code that is set in the code query parameter of the redirect URL.

⚠ NOTE: This property is going to be included in the URL, so make sure it does not hint at sensitive errors.

The full error is always logged on the server, if you need to debug.

Generally, we don’t recommend hinting specifically if the user had either a wrong username or password specifically, try rather something like “Invalid credentials”.

message

message: string;
Inherited from

SignInError.message

name

name: string;
Inherited from

SignInError.name

stack?

optional stack: string;
Inherited from

SignInError.stack

type

type: ErrorType;

The error type. Used to identify the error in the logs.

Inherited from

SignInError.type

kind

static kind: string = "signIn";
Inherited from

SignInError.kind

prepareStackTrace()?

static optional prepareStackTrace: (err, stackTraces) => any;

Optional override for formatting stack traces

See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

Inherited from

SignInError.prepareStackTrace

stackTraceLimit

static stackTraceLimit: number;
Inherited from

SignInError.stackTraceLimit

type

static type: string = "CredentialsSignin";

Methods

captureStackTrace()

static captureStackTrace(targetObject, constructorOpt?): void

Create .stack property on a target object

Parameters
ParameterType
targetObjectobject
constructorOpt?Function
Returns

void

Inherited from

SignInError.captureStackTrace


DuplicateConditionalUI

Thrown when multiple providers have enableConditionalUI set to true. Only one provider can have this option enabled at a time.

Extends

Constructors

new DuplicateConditionalUI(message, errorOptions)

new DuplicateConditionalUI(message?, errorOptions?): DuplicateConditionalUI
Parameters
ParameterType
message?string | ErrorOptions
errorOptions?ErrorOptions
Returns

DuplicateConditionalUI

Inherited from

AuthError.constructor

Properties

cause?

optional cause: Record<string, unknown> & {
  err: Error;
};
Type declaration
err?
optional err: Error;
Inherited from

AuthError.cause

message

message: string;
Inherited from

AuthError.message

name

name: string;
Inherited from

AuthError.name

stack?

optional stack: string;
Inherited from

AuthError.stack

type

type: ErrorType;

The error type. Used to identify the error in the logs.

Inherited from

AuthError.type

prepareStackTrace()?

static optional prepareStackTrace: (err, stackTraces) => any;

Optional override for formatting stack traces

See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

Inherited from

AuthError.prepareStackTrace

stackTraceLimit

static stackTraceLimit: number;
Inherited from

AuthError.stackTraceLimit

type

static type: string = "DuplicateConditionalUI";

Methods

captureStackTrace()

static captureStackTrace(targetObject, constructorOpt?): void

Create .stack property on a target object

Parameters
ParameterType
targetObjectobject
constructorOpt?Function
Returns

void

Inherited from

AuthError.captureStackTrace


EmailSignInError

Happens when the login by an Email provider could not be started.

Possible causes are:

  • The email sent from the client is invalid, could not be normalized by EmailConfig.normalizeIdentifier
  • The provided email/token combination has expired: Ask the user to log in again.
  • There was an error with the database: Check the database logs.

Extends

Constructors

new EmailSignInError(message, errorOptions)

new EmailSignInError(message?, errorOptions?): EmailSignInError
Parameters
ParameterType
message?string | ErrorOptions
errorOptions?ErrorOptions
Returns

EmailSignInError

Inherited from

SignInError.constructor

Properties

cause?

optional cause: Record<string, unknown> & {
  err: Error;
};
Type declaration
err?
optional err: Error;
Inherited from

SignInError.cause

message

message: string;
Inherited from

SignInError.message

name

name: string;
Inherited from

SignInError.name

stack?

optional stack: string;
Inherited from

SignInError.stack

type

type: ErrorType;

The error type. Used to identify the error in the logs.

Inherited from

SignInError.type

kind

static kind: string = "signIn";
Inherited from

SignInError.kind

prepareStackTrace()?

static optional prepareStackTrace: (err, stackTraces) => any;

Optional override for formatting stack traces

See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

Inherited from

SignInError.prepareStackTrace

stackTraceLimit

static stackTraceLimit: number;
Inherited from

SignInError.stackTraceLimit

type

static type: string = "EmailSignInError";

Methods

captureStackTrace()

static captureStackTrace(targetObject, constructorOpt?): void

Create .stack property on a target object

Parameters
ParameterType
targetObjectobject
constructorOpt?Function
Returns

void

Inherited from

SignInError.captureStackTrace


ErrorPageLoop

Thrown when Auth.js is misconfigured and accidentally tried to require authentication on a custom error page. To prevent an infinite loop, Auth.js will instead render its default error page.

To fix this, make sure that the error page does not require authentication.

Learn more at Guide: Error pages

Extends

Constructors

new ErrorPageLoop(message, errorOptions)

new ErrorPageLoop(message?, errorOptions?): ErrorPageLoop
Parameters
ParameterType
message?string | ErrorOptions
errorOptions?ErrorOptions
Returns

ErrorPageLoop

Inherited from

AuthError.constructor

Properties

cause?

optional cause: Record<string, unknown> & {
  err: Error;
};
Type declaration
err?
optional err: Error;
Inherited from

AuthError.cause

message

message: string;
Inherited from

AuthError.message

name

name: string;
Inherited from

AuthError.name

stack?

optional stack: string;
Inherited from

AuthError.stack

type

type: ErrorType;

The error type. Used to identify the error in the logs.

Inherited from

AuthError.type

prepareStackTrace()?

static optional prepareStackTrace: (err, stackTraces) => any;

Optional override for formatting stack traces

See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

Inherited from

AuthError.prepareStackTrace

stackTraceLimit

static stackTraceLimit: number;
Inherited from

AuthError.stackTraceLimit

type

static type: string = "ErrorPageLoop";

Methods

captureStackTrace()

static captureStackTrace(targetObject, constructorOpt?): void

Create .stack property on a target object

Parameters
ParameterType
targetObjectobject
constructorOpt?Function
Returns

void

Inherited from

AuthError.captureStackTrace


EventError

One of the events methods failed during execution.

Make sure that the events methods are implemented correctly and uncaught errors are handled.

Learn more at events

Extends

Constructors

new EventError(message, errorOptions)

new EventError(message?, errorOptions?): EventError
Parameters
ParameterType
message?string | ErrorOptions
errorOptions?ErrorOptions
Returns

EventError

Inherited from

AuthError.constructor

Properties

cause?

optional cause: Record<string, unknown> & {
  err: Error;
};
Type declaration
err?
optional err: Error;
Inherited from

AuthError.cause

message

message: string;
Inherited from

AuthError.message

name

name: string;
Inherited from

AuthError.name

stack?

optional stack: string;
Inherited from

AuthError.stack

type

type: ErrorType;

The error type. Used to identify the error in the logs.

Inherited from

AuthError.type

prepareStackTrace()?

static optional prepareStackTrace: (err, stackTraces) => any;

Optional override for formatting stack traces

See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

Inherited from

AuthError.prepareStackTrace

stackTraceLimit

static stackTraceLimit: number;
Inherited from

AuthError.stackTraceLimit

type

static type: string = "EventError";

Methods

captureStackTrace()

static captureStackTrace(targetObject, constructorOpt?): void

Create .stack property on a target object

Parameters
ParameterType
targetObjectobject
constructorOpt?Function
Returns

void

Inherited from

AuthError.captureStackTrace


ExperimentalFeatureNotEnabled

Thrown when an experimental feature is used but not enabled.

Extends

Constructors

new ExperimentalFeatureNotEnabled(message, errorOptions)

new ExperimentalFeatureNotEnabled(message?, errorOptions?): ExperimentalFeatureNotEnabled
Parameters
ParameterType
message?string | ErrorOptions
errorOptions?ErrorOptions
Returns

ExperimentalFeatureNotEnabled

Inherited from

AuthError.constructor

Properties

cause?

optional cause: Record<string, unknown> & {
  err: Error;
};
Type declaration
err?
optional err: Error;
Inherited from

AuthError.cause

message

message: string;
Inherited from

AuthError.message

name

name: string;
Inherited from

AuthError.name

stack?

optional stack: string;
Inherited from

AuthError.stack

type

type: ErrorType;

The error type. Used to identify the error in the logs.

Inherited from

AuthError.type

prepareStackTrace()?

static optional prepareStackTrace: (err, stackTraces) => any;

Optional override for formatting stack traces

See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

Inherited from

AuthError.prepareStackTrace

stackTraceLimit

static stackTraceLimit: number;
Inherited from

AuthError.stackTraceLimit

type

static type: string = "ExperimentalFeatureNotEnabled";

Methods

captureStackTrace()

static captureStackTrace(targetObject, constructorOpt?): void

Create .stack property on a target object

Parameters
ParameterType
targetObjectobject
constructorOpt?Function
Returns

void

Inherited from

AuthError.captureStackTrace


InvalidCallbackUrl

Thrown when Auth.js is unable to verify a callbackUrl value. The browser either disabled cookies or the callbackUrl is not a valid URL.

Somebody might have tried to manipulate the callback URL that Auth.js uses to redirect the user back to the configured callbackUrl/page. This could be a malicious hacker trying to redirect the user to a phishing site. To prevent this, Auth.js checks if the callback URL is valid and throws this error if it is not.

There is no action required, but it might be an indicator that somebody is trying to attack your application.

Extends

Constructors

new InvalidCallbackUrl(message, errorOptions)

new InvalidCallbackUrl(message?, errorOptions?): InvalidCallbackUrl
Parameters
ParameterType
message?string | ErrorOptions
errorOptions?ErrorOptions
Returns

InvalidCallbackUrl

Inherited from

AuthError.constructor

Properties

cause?

optional cause: Record<string, unknown> & {
  err: Error;
};
Type declaration
err?
optional err: Error;
Inherited from

AuthError.cause

message

message: string;
Inherited from

AuthError.message

name

name: string;
Inherited from

AuthError.name

stack?

optional stack: string;
Inherited from

AuthError.stack

type

type: ErrorType;

The error type. Used to identify the error in the logs.

Inherited from

AuthError.type

prepareStackTrace()?

static optional prepareStackTrace: (err, stackTraces) => any;

Optional override for formatting stack traces

See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

Inherited from

AuthError.prepareStackTrace

stackTraceLimit

static stackTraceLimit: number;
Inherited from

AuthError.stackTraceLimit

type

static type: string = "InvalidCallbackUrl";

Methods

captureStackTrace()

static captureStackTrace(targetObject, constructorOpt?): void

Create .stack property on a target object

Parameters
ParameterType
targetObjectobject
constructorOpt?Function
Returns

void

Inherited from

AuthError.captureStackTrace


InvalidCheck

Thrown when a PKCE, state or nonce OAuth check could not be performed. This could happen if the OAuth provider is configured incorrectly or if the browser is blocking cookies.

Learn more at checks

Extends

Constructors

new InvalidCheck(message, errorOptions)

new InvalidCheck(message?, errorOptions?): InvalidCheck
Parameters
ParameterType
message?string | ErrorOptions
errorOptions?ErrorOptions
Returns

InvalidCheck

Inherited from

AuthError.constructor

Properties

cause?

optional cause: Record<string, unknown> & {
  err: Error;
};
Type declaration
err?
optional err: Error;
Inherited from

AuthError.cause

message

message: string;
Inherited from

AuthError.message

name

name: string;
Inherited from

AuthError.name

stack?

optional stack: string;
Inherited from

AuthError.stack

type

type: ErrorType;

The error type. Used to identify the error in the logs.

Inherited from

AuthError.type

prepareStackTrace()?

static optional prepareStackTrace: (err, stackTraces) => any;

Optional override for formatting stack traces

See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

Inherited from

AuthError.prepareStackTrace

stackTraceLimit

static stackTraceLimit: number;
Inherited from

AuthError.stackTraceLimit

type

static type: string = "InvalidCheck";

Methods

captureStackTrace()

static captureStackTrace(targetObject, constructorOpt?): void

Create .stack property on a target object

Parameters
ParameterType
targetObjectobject
constructorOpt?Function
Returns

void

Inherited from

AuthError.captureStackTrace


InvalidEndpoints

One of the configured OAuth or OIDC providers is missing the authorization, token or userinfo, or issuer configuration. To perform OAuth or OIDC sign in, at least one of these endpoints is required.

Learn more at OAuth2Config or Guide: OAuth Provider

Extends

Constructors

new InvalidEndpoints(message, errorOptions)

new InvalidEndpoints(message?, errorOptions?): InvalidEndpoints
Parameters
ParameterType
message?string | ErrorOptions
errorOptions?ErrorOptions
Returns

InvalidEndpoints

Inherited from

AuthError.constructor

Properties

cause?

optional cause: Record<string, unknown> & {
  err: Error;
};
Type declaration
err?
optional err: Error;