Implemented an authentication system using the latest Next Auth V5 (Auth.js).
- Credentials Login
- OAuth (Google & Github)
- Forgot Password
- Email Verification
- Two Factor Authentication (2FA)
- Next.js / TailwindCSS
- Auth.js
- Prisma ORM
- Neon for PostgreSQL
- Zod for Typescript
- Resend for email
- Shadcn/ui
- Clone the repository:
git clone https://github.com/ranepaarth/next-auth-advanced.git
- Navigate to the project directory:
cd next-auth-advanced
- Install the dependencies:
npm install
Add a .env file in the root directory and follow
# PostgreSQL databse URL after you setup neon.tech from https://neon.tech/docs/connect/connect-from-any-app
DATABASE_URL
# This is the only strictly required environment variable. It is the secret used to encode the JWT and encrypt things in transit
# This can be generated via the CLI with npm exec auth secret or via openssl with "openssl rand -base64 33".
AUTH_SECRET
# For development http://localhost:3000
# After deployment this will cahnge to your domain: e.g. https://example.com
AUTH_URL
# Refer https://authjs.dev/getting-started/providers/github to setup env values
AUTH_GITHUB_CLIENT_ID={CLIENT_ID}
AUTH_GITHUB_CLIENT_SECRET={CLIENT_SECRET}
# Refer https://authjs.dev/getting-started/providers/google to setup env values
AUTH_GOOGLE_CLIENT_ID={CLIENT_ID}
AUTH_GOOGLE_CLIENT_SECRET={CLIENT_SECRET}
# Refer https://resend.com/docs/send-with-nextjs to setup env values
RESEND_API_KEY={RESEND_API_TOKEN}
- Start development server
npm run dev
- Get your prisma studio up and running using
npx prisma studio
command and visit http://localhost:5555 to start editing in your database. - Open your Browser and visit http://localhost:3000 to view the website
- NextJs 14 App routing
- Server Actions
- Server & Client components
- Zod schema validation
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.