This project is an authentication template built with Next.js 15, Lucia-auth, and Drizzle. The setup is designed to handle both OAuth2 (Google, GitHub) and magic link authentication (via Resend) with features similar to Vercel's authentication system.
- Sign-up & Sign-in: Two authentication strategies:
- OAuth2 (Google, GitHub)
- Magic links (Resend)
- Form validation: Robust validation for both sign-up and sign-in flows.
- Separate flows for each strategy: You cannot sign in without first signing up.
- Route protection: Guarded routes for authorized and non-authorized users.
- Server-side get user function: Efficiently fetches user data on the server.
- Email templates: Built with React-Email components for a consistent design.
- Shadcn UI components: Includes dark and light mode support.
-
Clone the repository:
git clone https://github.com/Soufi-MA/next15-drizzle-postgres-lucia-auth-template cd next15-drizzle-postgres-lucia-auth-template
-
Install dependencies:
npm install
-
Set up environment variables:
Copy the .env.example file and rename it to .env. Fill in the required values for OAuth providers, magic link configuration, database URL, etc.
cp .env.example .env
-
Run the development server:
npm run dev
Custom scripts are available for managing Drizzle database migrations and exploring the schema:
-
Generate a new migration:
npm run migration:generate
-
Push the migration to the database:
npm run migration:push
-
Open Drizzle Studio to explore the schema:
npm run studio
Feel free to fork this repository, open issues, or submit pull requests with improvements.
This project is licensed under the MIT License.