Enterprise single sign-on
Users authenticate through an Okta organization in a Next.js application.
Auth.js · Const
Okta is a built-in Auth.js OpenID Connect provider. Register it in your framework configuration and provide AUTH_OKTA_ID, AUTH_OKTA_SECRET, and AUTH_OKTA_ISSUER through environment variables.
The Okta provider is a built-in OpenID Connect integration. Add it to the framework's Auth.js configuration; Auth.js can infer its client ID, client secret, and issuer from the documented AUTH_OKTA_ID, AUTH_OKTA_SECRET, and AUTH_OKTA_ISSUER environment variables.
Okta| Name | Type | Description |
|---|---|---|
options | OAuthUserConfig<P> | OAuth user configuration for the Okta profile, including values such as client ID, client secret, and issuer when supplied explicitly. |
OAuthConfig<P>
/api/auth/callback/okta.import NextAuth from "next-auth"
import Okta from "next-auth/providers/okta"
export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [Okta],
})With the documented AUTH_OKTA_* environment variables configured, this registers Okta as an authentication provider in a Next.js Auth.js application.
Users authenticate through an Okta organization in a Next.js application.
A service needs standard OIDC login without implementing discovery and authorization endpoints itself.
An application uses separate Okta tenants or deployment environments.
Okta is registered through the built-in provider and added to the providers list. In a Next.js application, the documented setup uses Okta directly, while the provider-specific environment variables supply its credentials and issuer.
Follow-up: What callback URL should be configured? For Next.js, use https://example.com/api/auth/callback/okta, replacing the hostname with the deployed application's domain.
Set AUTH_OKTA_ID, AUTH_OKTA_SECRET, and AUTH_OKTA_ISSUER. Auth.js uses environment-variable inference, so the provider can be included without explicitly passing those values in the configuration.
Follow-up: What if inference is insufficient? Call the provider with options, such as Okta({ clientId, clientSecret, issuer }), to provide or override configuration explicitly.
The provider factory accepts OAuth user configuration for an Okta profile and returns an OAuth configuration for that profile. The built-in defaults are intended for Okta's OpenID Connect setup.
Follow-up: How can a default be changed? Use the provider function with only the options that need changing; Auth.js deeply merges those overrides with the defaults.
OAuthConfigOktaProfilecustomizing a built-in OAuth providerenvironment variable inferenceAuth.js OAuth providers