How andrejfg/msal-dinamico works
Project type and purpose
• This is a full-stack, server-rendered web application built with Next.js (App Router v14) and React, focused on integrating Azure AD authentication via MSAL.
• Key use cases: user sign-in/sign-out, role-based page protection (admin only), and token retrieval for calling custom APIs or Microsoft Graph.
File structure
• app/: Next.js App Router pages and layouts (SSR)
• app/layout.tsx – global layout, wraps all pages
• app/page.tsx – public landing page
• app/adminonlypage/page.tsx – protected “admin only” page
• app/gettokentest/page.tsx – page to display acquired token
• app/globals.css – global Tailwind CSS styles
• components/: React UI components (SignInButton, SignOutButton, UnauthorizedMessage, UserAvatar, etc.)
• hooks/: custom React hooks (useCopyToClipboard)
• msal/: encapsulates all MSAL setup and helpers
• MsalConfigProvider.tsx, MyMsalProvider.tsx – context providers for MSAL
• msal.ts / authConfig.js – client & auth configuration
• tokenFetcher.ts – utility to acquire tokens programmatically
• msalGraph.ts, userHelper.ts – wrappers for calling Microsoft Graph and user utilities
• config files: next.config.js, tsconfig.json, tailwind.config.ts, postcss.config.js
• others: .env.local for NEXT_PUBLIC_USER_CLAIMS_ADMIN, package.json, .eslintrc.json
Insights from the README
• Tech stack: Next.js v14, React 18, @azure/msal-browser v3.6.0, msal-react v2.0.8, Tailwind CSS
• Purpose: streamline Azure AD auth in an SSR React app
• Workflow: user logs in via MSAL → receives tokens → app checks claims for authorization → optionally calls MS Graph or a custom API using acquired tokens