This Next.js template integrates PostgreSQL for database management, Auth.js for Google and GitHub authentication, and Drizzle as the ORM. It provides features like Google and GitHub authentication, role-based user authentication, and a user management page.
- Google and GitHub authentication
- Role-based user authentication with a visually appealing login page
- User Management page
Clone the repository and delete the .git folder to initialize your own git repository.
git clone https://github.com/mohitkumaragrawal/next-auth-drizzle-template.git
Then, install dependencies using pnpm.
pnpm i
Copy the .env.example file to .env.
-
Create your own Github OAuth Client
-
Add http://localhost:3000/api/auth/callback/github to the callback url
-
Copy the respective GITHUB_ID and GITHUB_SECRET to the
.env
file
- Google OAuth Configuration
- Callback Url: http://localhost:3000/api/auth/callback/google
- Copy the respective GOOGLE_ID and GOOGLE_SECRET to the .env file
- Run this command to generate the NEXTAUTH_SECRET
openssl rand -base64 32
-
I'm using Docker to spin up PostgreSQL just install docker and run
sudo docker-compose up -d
-
Create all the required tables in the database using
pnpm db:push
- Run the development server
pnpm dev
- Optionally, open Drizzle Studio using pnpm db:studio and assign the owner role to yourself by adding a row in the userRole table with your user ID as the userId and owner as the role.
Now, you're ready to start developing with this Next.js template!