Skip to content

About

A Next.js app with NextAuth for authentication, using Auth0 as the provider.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

NextAuth-auth0-NextJS

Next.js NextAuth Auth0 Tailwind CSS

🔐 Next.js 13 App Router with Auth0 login, protected routes, and middleware — ready to extend 🛡️


✨ Features

  • 🔑 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 — useToken to retrieve the JWT, useFetch for authenticated API calls

🚀 Quick Start

1. Install

npm install

2. Configure Auth0

Create .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.com

In your Auth0 dashboard, add http://localhost:3000/api/auth/callback/auth0 as an allowed callback URL.

3. Run

npm run dev

Open http://localhost:3000 — click login to be redirected to Auth0, then land on the protected dashboard.

🏗️ Project Structure

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

🛠️ Tech Stack

  • Next.js 13 (App Router)
  • NextAuth v4 — session management
  • Auth0 — identity provider
  • TypeScript
  • Tailwind CSS

About

A Next.js app with NextAuth for authentication, using Auth0 as the provider.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages