Enterprise authentication
Add Azure AD sign-in to a Next.js Auth.js application.
Auth.js · Const
AzureAD is Auth.js’s built-in Azure Active Directory OIDC provider. It is deprecated in favor of the Microsoft Entra ID provider because Azure Active Directory was renamed.
AzureAD is Auth.js’s built-in OpenID Connect integration for Azure Active Directory. Calling the provider factory creates an OIDC configuration from client settings, optionally including a supported profile-photo size; the documentation recommends Microsoft Entra ID for new integrations because Azure AD has been renamed.
function default(config): OIDCConfig<MicrosoftEntraIDProfile>| Name | Type | Description |
|---|---|---|
config | OIDCUserConfig<MicrosoftEntraIDProfile> & { profilePhotoSize: 64 | 48 | 96 | 120 | 240 | 360 | 432 | 504 | 648 } | OIDC user configuration plus the optional supported profile-photo size. |
OIDCConfig<MicrosoftEntraIDProfile>
import NextAuth from "next-auth"
import AzureAD from "next-auth/providers/azure-ad"
export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [AzureAD({
clientId: process.env.AUTH_AZURE_AD_CLIENT_ID,
clientSecret: process.env.AUTH_AZURE_AD_CLIENT_SECRET,
tenantId: process.env.AUTH_AZURE_AD_TENANT_ID,
})],
})Registers Azure AD as an Auth.js provider using application credentials and the tenant identifier.
Add Azure AD sign-in to a Next.js Auth.js application.
Connect an Auth.js application to an existing Azure tenant.
Maintain an existing application while planning provider migration.
AzureAD is a built-in Azure AD integration, and its factory returns an OIDCConfig<MicrosoftEntraIDProfile>. It accepts OIDC user configuration plus an optional profilePhotoSize constrained to the documented sizes.
Follow-up: What should a new application use instead? Use the Microsoft Entra ID provider submodule, since Azure Active Directory was renamed and the AzureAD provider is deprecated.
Configure the provider in the Auth.js providers array by calling AzureAD with the application client ID, client secret, and tenant ID. The provider then supplies the OIDC configuration used for sign-in.
Follow-up: Where should the credentials come from? Store the client ID, client secret, and tenant ID in environment variables rather than embedding secrets in source code.
The API reference aliases AzureADProfile to MicrosoftEntraIDProfile. This reflects the provider’s current identity model while retaining the AzureAD export name for compatibility.
Follow-up: What migration concern follows from that alias? New code should prefer the Microsoft Entra ID provider import rather than building further dependencies on the deprecated AzureAD name.
MicrosoftEntraIDProfileOIDCConfigOIDCUserConfigproviders/microsoft-entra-id