Setting Up Auth.js in Next.js App Router
Install Auth.js, configure route handlers, and add a GitHub OAuth provider.
What Is Auth.js?
Auth.js (formerly NextAuth.js v5) is a full-featured authentication library for Next.js. It handles OAuth providers, credentials, sessions, and JWT out of the box.
Installation
Install the Auth.js beta and initialize the config file.
npm install next-auth@beta
# Create auth.ts at project root
touch auth.tsAll lessons in this course
- Setting Up Auth.js in Next.js App Router
- Session Management & useSession Hook
- Credentials Provider & Custom Login
- Middleware-Based Route Protection