v5.1.0 — Multi-Tenant Support

Microsoft Auth for
Next.js App Router

Production-ready MSAL authentication with zero configuration.TypeScript-first, secure, and developer-friendly.

npx @chemmangat/msal-next-cli init
What's new
Version 5.1.0
Multi-Tenant
allowList, blockList, requireType and requireMFA — control exactly which tenants can sign in
useTenant() Hook
tenantId, tenantDomain, isGuestUser, homeTenantId — full B2B guest detection built-in
Per-Page Tenant Rules
export const auth = { tenant: { allowList, requireMFA } } — zero-config page protection
Cross-Tenant Tokens
acquireTokenForTenant(tenantId, scopes) — silent token acquisition for any tenant

Everything You Need for Microsoft Auth

Production-ready features that developers love

NEW in v5.0.0

CLI Init Command

Run npx init and answer a few prompts. The CLI writes .env.local, wires MSALProvider into layout.tsx, and creates a starter auth page — no boilerplate to copy.

Learn more
npx @chemmangat/msal-next-cli init
# ✔ Client ID?  97f1e8c5-...
# ✔ Tenant ID?  common
# ✔ Cache?      sessionStorage
# ✅ .env.local created
# ✅ layout.tsx updated
# ✅ app/auth/page.tsx created
2.9k+
Weekly Downloads
100%
TypeScript Coverage
5 min
Setup Time

Simple to Use

Scaffold a full auth setup in one command

terminal
# Scaffold everything interactively
npx @chemmangat/msal-next-cli init

# Migrate popup → redirect calls
npx @chemmangat/msal-next-cli migrate

# Or install the package directly
npm install @chemmangat/msal-next
1
Run init
CLI asks for client ID, tenant, cache location
2
Auto-wired
.env.local, layout.tsx and auth page created
3
Done
Sign in with Microsoft works immediately

Ready to get started?

Join thousands of developers using msal-next in production

Read Documentation