Next.js Lucia Email/Password Auth with Drizzle

R
Renaudil y a 2 jours
0

Description

Authentication with Lucia including email verification and password reset.

npx boilerapp nextjs-lucia-auth-email-password-reset-drizzle

文档

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.
  • E2E tests: 🧪 Catch every issue before your users do with comprehensive E2E testing.
  • Stripe Payment: 💳 Setup user subscriptions seamlessly with stripe.
  • Email template with react-email: ✉️ Craft your email templates using React.
  • PostgreSQL Database: 🛢️ Utilize a PostgreSQL database 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. (for node v18 or lower): Uncomment polyfills for webCrypto in src/lib/auth/index.ts
  5. Update app title, database prefix, and other parameters in the src/lib/constants.ts file.
  6. Run pnpm db:push to push your schema to the database.
  7. Execute pnpm dev to start the development server and enjoy!

Testing

  1. Install Playwright (use this command if you want to install chromium only pnpm exec playwright install chromium --with-deps)
  2. Build production files using pnpm build
  3. Run pnpm test:e2e (add --debug flag to open tests in browser in debug mode)

Using Github actions

Add the following environment variables to your github actions repository secrets - DATABASE_URL, DISCORD_CLIENT_ID, DISCORD_CLIENT_SECRET

Roadmap

  • Update Password
  • Stripe Integration
<!-- - [x] API Rate-Limiting see branch - [upstash-ratelimiting](https://github.com/iamtouha/next-lucia-auth/tree/upstash-ratelimiting) -->
  • Admin Dashboard (under consideration)
  • Role-Based Access Policy (under consideration)

Contributing

To contribute, fork the repository and create a feature branch. Test your changes, and if possible, open an issue for discussion before submitting a pull request. Follow project guidelines, and welcome feedback to ensure a smooth integration of your contributions. Your pull requests are warmly welcome.

Prix

Gratuit

FREE

评论 (0)

常见问题

常见问题解答 (FAQ)

有问题?我们有答案。如果您找不到想要的答案,请随时联系我们。

Boilerapp 是一个专门用于分享 Boilerplates、入门套件(Starter Kits)和项目模版的开发者社区平台。我们的目标很简单:为您节省初始配置(Setup)的时间,让您可以专注于真正重要的代码。无论您是在寻找简单的代码库还是完整的 SaaS 项目,都能在这里找到。

还有其他问题?

我们的团队随时为您提供帮助。联系我们,我们将尽快回复。