75asa / next-lucia-auth_demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Next.js Auth Starter Template

Motivation

Implementing authentication in Next.js, especially Email+Password authentication, can be challenging. NextAuth intentionally limits email password functionality to discourage the use of passwords due to security risks and added complexity. However, in certain projects, clients may require user password authentication. Lucia offers a flexible alternative to NextAuth.js, providing more customization options without compromising on security. This template serves as a starting point for building a Next.js app with Lucia authentication.

Lucia vs. NextAuth.js

Lucia is less opinionated than NextAuth, offering greater flexibility for customization. While Lucia involves more setup, it provides a higher degree of flexibility, making it a suitable choice for projects requiring unique authentication configurations.

Key Features

  • Authentication: πŸ’Ό Support for Credential and OAuth authentication.
  • Authorization: πŸ”’ Easily manage public and protected routes within the app directory.
  • Email Verification: πŸ“§ Verify user identities through email.
  • Password Reset: πŸ”‘ Streamline password resets by sending email password reset links.
  • Lucia + tRPC: πŸ”„ Similar to NextAuth with tRPC, granting access to sessions and user information through tRPC procedures.
  • Email template with react-email: βœ‰οΈ Craft your email templates using React.
  • MySQL Database: πŸ›’οΈ Utilize a MySQL database (Planetscale) set up using Drizzle for enhanced performance and type safety.
  • Database Migration: πŸš€ Included migration script to extend the database schema according to your project needs.

Tech Stack

Get Started

  1. Clone this repository to your local machine.
  2. Copy .env.example to .env and fill in the required environment variables.
  3. Run pnpm install to install dependencies.
  4. Update app title, database prefix, and other parameters in the src/lib/constants.ts file.
  5. Run pnpm db:push to push your schema to the database.
  6. Execute pnpm dev to start the development server and enjoy!

Roadmap

  • Update Password
  • Stripe Integration
  • API Rate-Limiting
  • Admin Dashboard (under consideration)
  • Role-Based Access Policy (under consideration)

Contributing

If you wish to contribute, fork the repository and use a feature branch. Pull requests are warmly welcome.

About

License:MIT License


Languages

Language:TypeScript 96.2%Language:JavaScript 2.4%Language:CSS 1.4%