Next-15-Azure-Auth is a starter template for building secure Next.js v15+ Tailwind apps with Microsoft Entra ID authentication. It uses the Next-Auth.js Library for authentication and the Microsoft Graph Client Library for fetching user data.
Ensure the following are installed before running the application locally:
Register the Application
Next-15-Azure-Auth
).http://localhost:3000/api/auth/callback/microsoft-entra-id
Configure the Application
.env
file as AUTH_MICROSOFT_ENTRA_ID_ID
..env
file as AUTH_MICROSOFT_ENTRA_ID_ISSUER
.Next-15-Azure-Auth Secret
) and choose an expiration period..env
file as AUTH_MICROSOFT_ENTRA_ID_SECRET
.Set Up API Permissions
User.Read
- for accessing user detailsopenid
- for OpenID Connect authenticationemail
- for email accessprofile
- for basic profile infooffline_access
- for refresh tokens(Optional) Create an Enterprise Application
Clone the Repository
git clone https://github.com/matt-wigg/next-15-azure-auth.git
cd next-15-azure-auth
Install Dependencies
npm install
Set Up Environment Variables
Create a (or edit the) .env
file in the root directory:
AUTH_SECRET=your_auth_secret
AUTH_MICROSOFT_ENTRA_ID_ID=your_azure_client_id
AUTH_MICROSOFT_ENTRA_ID_SECRET=your_azure_client_secret
AUTH_MICROSOFT_ENTRA_ID_ISSUER=your_azure_tenant_id
To generate the AUTH_SECRET
, run:
openssl rand -base64 32
Start the Development Server
npm run dev
Your application will be available at http://localhost:3000
.