- 🔑 Auth0 login wired through NextAuth v4 — no custom auth logic needed
- 🚪 Protected
/dashboard— unauthenticated users are redirected automatically - 🧱 Middleware-based protection — route guards at the edge
- 🪝 Custom hooks —
useTokento retrieve the JWT,useFetchfor authenticated API calls
npm installCreate .env.local:
NEXTAUTH_SECRET=any-random-string
NEXTAUTH_URL=http://localhost:3000
AUTH0_CLIENT_ID=your-auth0-client-id
AUTH0_CLIENT_SECRET=your-auth0-client-secret
AUTH0_ISSUER=https://your-tenant.auth0.comIn your Auth0 dashboard, add http://localhost:3000/api/auth/callback/auth0 as an allowed callback URL.
npm run devOpen http://localhost:3000 — click login to be redirected to Auth0, then land on the protected dashboard.
src/
├── app/
│ ├── api/auth/[...nextauth]/ # NextAuth route handler
│ ├── dashboard/ # Protected page
│ └── page.tsx # Public home
├── components/ # Navbar, LoadingScreen
├── hooks/ # useToken, useFetch
└── middleware.ts # Route protection
- Next.js 13 (App Router)
- NextAuth v4 — session management
- Auth0 — identity provider
- TypeScript
- Tailwind CSS
