Create T3 App + Lucia - Simple email password Authentication for Nextjs

Dec 27, 2023 2 min read

Implement email+password authentication in your nextjs app with lucia, A more flexible alternative to NextAuth.js

Create T3 App + Lucia Authentication

Auth implementation for Nextjs is a pain. Specially Email+Password authentication. NextAuth intentionally limeted email password functionality to-

discourage use of passwords due to the inherent security risks associated with them and the additional complexity associated with supporting usernames and passwords.

But in some projects clients require user password authentication. Using 3rd party auth providers are costly. Here, lucia comes to the rescure. Lucia is a more flexible alternative to NextAuth.js. This template is a starting point for building a Next.js app with Lucia authentication.

Github Repository Link

Lucia is a server-side authentication library for TypeScript that aims to be unintrusive, straightforward, and flexible. At its core, it’s a library for managing users and sessions, providing the building blocks for setting up auth just how you want.

Lucia v/s NextAuth.js (Auth.js)

Lucia is less opinionated than Next Auth. NextAuth is too rigid if you want to customize it. Although lucia has more setup but with that comes so much more flexibility.

Key Features

Tech Stack

Get Started

  1. Clone the repository git clone https://github.com/iamtouha/next-lucia-auth.git.
  2. Copy .env.example to .env and fill in the necessary environment variables.
  3. Run pnpm install to install dependencies.
  4. Update app title, database prefix and other parameters from src/lib/constants.ts file.
  5. Run pnpm db:push to push your schema to database.
  6. pnpm dev and enjoy!

Made with Astro, Tailwind CSS, and Vercel.