Next.js Lucia Email/Password Auth with Drizzle

Next.js Lucia Email/Password Auth with Drizzle
Type: Code
Framework: Next.js
CSS: Tailwind
  • Motivation: Addressing the challenge of implementing Email+Password authentication in Next.js projects, this template introduces Lucia as a flexible and secure alternative to NextAuth.js for projects that require traditional password-based user authentication.
  • Lucia vs. NextAuth.js:
    • Flexibility: Lucia provides more customization options compared to the more opinionated NextAuth.js.
    • Setup: While requiring more initial setup, Lucia offers greater adaptability for unique authentication needs.
  • Key Features:
    • Authentication: Supports both Credential and OAuth authentication methods.
    • Authorization: Facilitates the management of public and protected routes.
    • Email Verification: Enhances security by verifying user identities via email.
    • Password Reset: Simplifies the password reset process with email links.
    • Integration with tRPC: Enables access to session and user information similar to NextAuth, but with tRPC.
    • Email Templates: Utilize React for crafting email templates with react-email.
    • Database: Incorporates a MySQL database (Planetscale) optimized with Drizzle ORM for performance and safety.
    • Database Migration: Comes with a script for easy database schema extensions.
  • Tech Stack: Built with Next.js, Lucia, tRPC, Drizzle ORM, Planetscale, Tailwind CSS, Shadcn UI, React Hook Form, and React Email.
  • Getting Started:
    • Clone the repository, set up environment variables from .env.example, install dependencies with pnpm install, configure the app in src/lib/constants.ts, push the schema with pnpm db:push, and start the server with pnpm dev.
  • Roadmap: Future updates may include password updates, Stripe integration, API rate-limiting, an admin dashboard, and role-based access policies.
  • Contributing: Contributions are encouraged through forking the repository and submitting pull requests on feature branches.

Sign In

Register

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.