Options
All
  • Public
  • Public/Protected
  • All
Menu

Module config

Index

Server Interfaces

server Interfaces

Server Type aliases

Server Type aliases

ConfigParameters

ConfigParameters: DeepPartial<BaseConfig & NextConfig>

The Server part of the SDK can be configured in 2 ways.

1. Environmental Variables

The simplest way to use the SDK is to use the named exports (HandleAuth, HandleLogin, HandleLogout, HandleCallback, HandleProfile, GetSession, GetAccessToken, WithApiAuthRequired and WithPageAuthRequired), eg:

// pages/api/auth/[...auth0].js
import { handleAuth } from '@auth0/nextjs-auth0';

return handleAuth();

When you use these named exports, an instance of the SDK is created for you which you can configure using environmental variables:

Required

Optional

2. Create your own instance using InitAuth0

If you don't want to configure the SDK with environment variables or you want more fine grained control over the instance, you can create an instance yourself and use the handlers and helpers from that.

First, export your configured instance from another module:

// utils/auth0.js
import { initAuth0 } from '@auth0/nextjs-auth0';

export default initAuth0({ ...ConfigParameters... });

Then import it into your route handler:

// pages/api/auth/[...auth0].js
import auth0 from '../../../../utils/auth0';

return auth0.handleAuth();

Note If you use InitAuth0, you should not use the other named exports as they will use a different instance of the SDK.