This project was created to learn and implement Auth.js v5 (formerly NextAuth.js) for authentication in a Next.js app. The learning process followed a highly detailed tutorial by Code With Antonio (Antonio Erdeljac) from GitHub - AntonioErdeljac.
This template demonstrates how to integrate Auth.js v5 into a Next.js application using the App Router. The project includes multiple authentication providers, such as GitHub, Google, and custom credentials.
- Authentication Providers:
- Credentials
- OAuth (Google & GitHub)
- Two-Factor Authentication (2FA)
- Email Verification using Resend for sending mails
- Protected Routes: Restrict access to specific parts of the app to authenticated users
- User Session Management: Efficient session handling to manage user login states
- PostgreSQL Integration with Prisma ORM
- Next.js (App Router)
- Auth.js v5
- PostgreSQL (with Prisma ORM)
- Resend (for email services)
- TypeScript
- Tailwind CSS (for styling)
-
Clone the repository:
git clone https://github.com/valik3201/next-auth-template cd next-auth-template
-
Install dependencies:
npm install
-
Configure environment variables for authentication providers and database connection:
- GitHub OAuth
- Google OAuth
- PostgreSQL connection string
- Resend API key for email services
-
Run Prisma migration:
npx prisma migrate dev
-
Start the development server:
npm run dev
This project was developed by following Code With Antonio's excellent tutorial.