Skip to content

An example showcasing the core principles of modern authentication using the Microsoft Identity Platform in Next.js version 14, utilizing MSAL React for client-side requests to Microsoft Graph.

License

Notifications You must be signed in to change notification settings

dwarfered/msal-nextjs-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MSAL Next.js Microsoft Graph SPA Quickstart

An example showcasing the core principles of modern authentication using the Microsoft Identity Platform in Next.js version 14, utilizing MSAL React for client-side requests to Microsoft Graph.

The Microsoft identity platform, incorporating Entra ID (Azure AD) and Azure Azure Active Directory B2C (Azure AD B2C) plays a pivotal role in the Azure cloud ecosystem. This example is designed to showcase the basics of modern authentication within a Nextjs framework, utilising the Microsoft Authentication Library for React (MSAL React).

Sample Prerequisites

Recommendations

ℹ️ "SWR is a strategy to first return the data from cache (stale), then send the fetch request (revalidate), and finally come with the up-to-date data."

Configure the application

  • Open ./lib/msalConfig.ts in an editor.
  • Replace Client and Authority for your created Entra Application Registration.

Installing dependencies

# Install dependencies from the root of the repo
npm install

Running the application

# Run locally
npm run dev

# Optionally build
npm run build
  1. Open http://localhost:3000 to view in your browser.
  2. Open http://localhost:3000/profile to view a protected route, that if signed in will display profile information.

Screenshots

Pending Sign In

Sign In

About

An example showcasing the core principles of modern authentication using the Microsoft Identity Platform in Next.js version 14, utilizing MSAL React for client-side requests to Microsoft Graph.

Topics

Resources

License

Stars

Watchers

Forks