npm install @azure/msal-browser
Any SPA framework works
Create an App Registration in Azure Entra ID portal. Configure the redirect URI and note the client ID and tenant ID.
1 import { Configuration, BrowserCacheLocation } from '@azure/msal-browser'; 2 3 export const msalConfig: Configuration = { 4 auth: { 5 clientId: process.env.NEXT_PUBLIC_AZURE_CLIENT_ID!, 6 authority: `https://login.microsoftonline.com/${process.env.NEXT_PUBLIC_AZURE_TENANT_ID}`, 7 redirectUri: process.env.NEXT_PUBLIC_REDIRECT_URI ?? 'http://localhost:3000/auth/callback', 8 }, 9 cache: { 10 cacheLocation: BrowserCacheLocation.SessionStorage, // Not localStorage 11 storeAuthStateInCookie: false, 12 }, 13 }; 14 15 export const loginRequest = { 16 scopes: ['openid', 'profile', 'email'], 17 }; 18
App Registration created with client ID and tenant ID visible
Sign in to share your feedback and join the discussion.