Auth0Client can be customized using configuration options passed to the constructor or via environment variables.
Basic Setup
Required Configuration
string
The Auth0 domain for your tenant (e.g.,
example.us.auth0.com or https://example.us.auth0.com).Environment variable: AUTH0_DOMAINstring
The Auth0 client ID for your application.Environment variable:
AUTH0_CLIENT_IDstring
A 32-byte, hex-encoded secret used for encrypting cookies. Generate using:Environment variable:
AUTH0_SECRETstring
The Auth0 client secret. Required unless using
clientAssertionSigningKey.Environment variable: AUTH0_CLIENT_SECRETOptional Configuration
Application Settings
string
The URL of your application (e.g.,
http://localhost:3000).If omitted, the SDK will infer it from the request host at runtime. This is useful for dynamic preview environments (Vercel, Netlify).Environment variable: APP_BASE_URLSecurity note: When using dynamic base URLs in production, the SDK enforces secure cookies. Explicitly setting secure=false will throw InvalidConfigurationError.string
default:"/"
The path to redirect users to after successful authentication.
boolean
default:"true"
Send library name and version to your authorization server via the
Auth0-Client header.number
default:"5000"
HTTP timeout in milliseconds for authentication requests.
boolean
default:"false"
Allow insecure requests to the authorization server (useful for testing with mock OIDC providers).Note: Can only be used when
NODE_ENV is not set to production.Authorization Parameters
AuthorizationParameters
Authorization parameters to pass to the See Passing authorization parameters for more details.
/authorize endpoint.Logout Configuration
'auto' | 'oidc' | 'v2'
default:"auto"
Strategy for logout endpoint selection:
auto: Uses OIDC logout when available, falls back to/v2/logoutoidc: Always uses OIDC logoutv2: Always uses/v2/logoutendpoint which supports wildcard URLs
boolean
default:"true"
Configure whether to include
id_token_hint in OIDC logout URLs.true(recommended): Includes ID token for better DoS protectionfalse: Excludes PII from logout URLs but reduces DoS protection
Session Configuration
SessionConfiguration
Configure session timeouts, rolling sessions, and cookie attributes.Cookie environment variables:
AUTH0_COOKIE_DOMAINAUTH0_COOKIE_PATHAUTH0_COOKIE_TRANSIENTAUTH0_COOKIE_SECUREAUTH0_COOKIE_SAME_SITE
httpOnly is always true for security.See Session Configuration and Cookie Configuration for details.SessionStore
Custom session store implementation for persisting sessions to an external data store.See Database sessions for details.
Transaction Cookies
boolean
default:"true"
Enable support for multiple concurrent authentication flows.
true: Each authentication attempt gets its own transaction cookie with a unique state suffixfalse: Uses a single shared transaction cookie (may cause conflicts with concurrent auth attempts)
TransactionCookieOptions
Configure transaction cookie management for authentication flows.See Transaction Cookie Configuration for details.
Advanced OAuth
string | CryptoKey
Private key for use with
private_key_jwt clients.Environment variable: AUTH0_CLIENT_ASSERTION_SIGNING_KEYstring
The algorithm used to sign the client assertion JWT.Environment variable:
AUTH0_CLIENT_ASSERTION_SIGNING_ALGboolean
default:"false"
Configure the SDK to use Pushed Authorization Requests (PAR) protocol when communicating with the authorization server.
DPoP (Demonstrating Proof-of-Possession)
boolean
default:"false"
Enable DPoP for enhanced security. When enabled, the client will generate DPoP proofs for token requests and protected resource requests.DPoP binds access tokens to cryptographic key pairs, preventing token theft and replay attacks.
DpopKeyPair
ES256 key pair for DPoP proof generation.If not provided, the SDK will attempt to load keys from environment variables:
AUTH0_DPOP_PUBLIC_KEY(PEM format)AUTH0_DPOP_PRIVATE_KEY(PEM format)
DpopOptions
Configure DPoP timing validation to handle clock differences between client and server.Environment variables:
AUTH0_DPOP_CLOCK_SKEW: Clock adjustment in secondsAUTH0_DPOP_CLOCK_TOLERANCE: Tolerance in seconds
Custom Routes
Routes
Hooks
BeforeSessionSavedHook
OnCallbackHook
A method to handle errors or manage redirects after attempting to authenticate.See onCallback for details.
Access Token Configuration
boolean
default:"true"
Enable the
/auth/access-token endpoint for client-side access token retrieval.Disable this if you don’t need access tokens on the client-side.number
default:"0"
Refresh access tokens this many seconds before they expire.Useful for ensuring tokens don’t expire mid-request.
Base Path Configuration
string
Set this environment variable when your Next.js application uses a base path (configured via
basePath in next.config.js).Example: If set to /dashboard, authentication routes will be mounted at:/dashboard/auth/login/dashboard/auth/callback/dashboard/auth/logout
NEXT_PUBLIC_BASE_PATH with an APP_BASE_URL that contains a path component. Set APP_BASE_URL to the root URL and use NEXT_PUBLIC_BASE_PATH for the base path.Configuration Validation
The SDK validates required configuration options when initializing theAuth0Client. Missing required options will result in a warning with details on how to provide them.
Required options:
domainorAUTH0_DOMAINclientIdorAUTH0_CLIENT_IDsecretorAUTH0_SECRET- Either:
clientSecretorAUTH0_CLIENT_SECRET, ORclientAssertionSigningKeyorAUTH0_CLIENT_ASSERTION_SIGNING_KEY
appBaseUrlorAPP_BASE_URL(inferred from request if omitted)
Environment Variables Summary
* Required unless using
AUTH0_CLIENT_ASSERTION_SIGNING_KEY
** Inferred from request host if omitted