Next.jsReactStarter

nextjs-sessionauth-template — Next.js Starter Template

By saasykits

A Next.js session authentication starter template integrating Lucia, tRPC, Drizzle ORM, PostgreSQL, Stripe, and React Email, providing credential and OAuth login, email verification, password reset, and protected routes.

Explore the design

Compare the page layouts and mobile experience. Open any screenshot for a closer look.

2 previews
Desktop homepage1 / 2
Desktop captureTop of page

Actual screenshot captured by the server browser.

All pages & views 2

Screenshots show visual appearance; interactive behavior may differ.

Recorded 2026-09-30View source

What stands out

A quick read of the recorded project description.

01

Uses Lucia for credential and OAuth authentication, replacing NextAuth's email-password limitations

02

Manages public and protected routes within the app directory

03

Includes email verification and password reset email flows

04

Accesses session and user information through tRPC procedures

05

Integrates Stripe user subscriptions and React Email email templates

06

Uses Drizzle ORM with PostgreSQL, with database migration scripts

Template Details

This is a Next.js starter template whose core goal is to address the implementation of email-plus-password authentication in Next.js. The README explains that NextAuth intentionally limits email-password functionality to reduce security risks and complexity, whereas this template uses Lucia as the authentication solution, offering more flexible customization and suiting projects that require user password authentication.

The template manages public and protected routes within the app directory, supports credential login and OAuth login, and includes email verification and password reset flows. Authentication sessions can be accessed via tRPC procedures, similar to how NextAuth and tRPC work together. The data layer uses Drizzle ORM to connect to PostgreSQL, with database migration scripts to extend the schema. For payments, Stripe is integrated for user subscriptions, and email templates are written using React Email. Testing uses Playwright for end-to-end tests.

The tech stack includes Next.js, React, Lucia, tRPC, Drizzle ORM, PostgreSQL, Stripe, Tailwind CSS, Shadcn UI, React Hook Form, React Email, and Playwright. The roadmap items for updating passwords, an admin dashboard, and role-based access policies are not yet complete; the Stripe integration is complete.

Next.jsReactStarter

Is it right for your project?

Use Cases

  • Next.js projects that need email-plus-password login and want to customize authentication logic
  • Web applications that need to support both credential login and OAuth login
  • Subscription products that require email verification and password reset flows
  • Teams that want to handle authentication sessions and business APIs uniformly with tRPC

Suitable For

  • Developers familiar with Next.js, TypeScript, and PostgreSQL
  • Projects that need a customizable authentication solution rather than a fixed authentication service
  • SaaS prototypes planning to integrate Stripe subscriptions and transactional emails
  • Teams that want to cover authentication flows with end-to-end tests

Getting started & customization

Use these recorded setup notes alongside the repository instructions for your chosen version.

  1. 1

    After cloning the repository, copy .env.example to .env and fill in the required environment variables

  2. 2

    Install dependencies using pnpm install

  3. 3

    On Node v18 or lower, uncomment the webCrypto polyfill in src/lib/auth/index.ts

  4. 4

    Update parameters such as the app title and database prefix in src/lib/constants.ts

  5. 5

    Run pnpm db:push to push the schema to the database, then run pnpm dev to start the development server

Read repository instructions

License & source material

Usage conditions & limitations

Free to use · keep license notice

This entry covers the free version under the MIT license in the public repository; the free scope is the code of this version and does not imply that external services or third-party assets are free.

Must comply with when using

  • Free use, modification, commercial use, and distribution of this version's code are permitted.
  • When distributing copies or substantial portions of the code, retain the original author's copyright notice and the full MIT license notice.
  • The code is provided as is; warranties and limitations of liability are governed by the original license and applicable law.

Additional costs & items to verify

  • Environment variables (such as database connection and OAuth client credentials) must be configured before use; you need to prepare a PostgreSQL database and third-party service accounts yourself.
  • Running in GitHub Actions requires configuring repository secrets such as DATABASE_URL, DISCORD_CLIENT_ID, and DISCORD_CLIENT_SECRET, i.e., it depends on an external database and Discord OAuth service.
  • The Stripe subscription feature depends on the external Stripe service and account, may incur transaction fees, and requires you to register and configure keys yourself.
  • End-to-end tests require additionally installing Playwright and its browser dependencies, which is an extra environment requirement.
  • When running on Node v18 or lower, you must manually uncomment the webCrypto polyfill, otherwise authentication features may be unavailable.
  • Demo images, fonts, icons, and other third-party assets must be checked against their respective licenses; the code's MIT license alone cannot be used to judge them.
  • External services such as domains, hosting, databases, payments, or AI may incur additional charges.
View Original Text Basis

Permission is hereby granted, free of charge

Original License Text

Copy `.env.example` to `.env` and fill in the required environment variables.

Original README

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

Original README

Setup user subscriptions seamlessly with stripe.

Original README

Install [Playwright](https://playwright.dev/) (use this command if you want to install chromium only `pnpm exec playwright install chromium --with-deps`)

Original README

`(for node v18 or lower):` Uncomment polyfills for `webCrypto` in `src/lib/auth/index.ts`

Original README
https://github.com/saasykits/nextjs-sessionauth-template/blob/main/LICENSEhttps://github.com/saasykits/nextjs-sessionauth-template/blob/main/README.md

Compiled by DeepSeek based on repository license and README ·2026-09-30. Results only cover the materials read; dependencies, images, fonts, and subsequent term changes are subject to their respective original texts.

Project checks & description sources

Template Information

Source platforms
GitHub
Documentation and maintenance reference score
More documented · 90 / 100
Technologies
Next.js · React
Website type
Starter
How this score is calculated

Our heuristic uses license records (up to 30), a demo link (12), a preview (10), stars (15), recorded maintenance (15), description completeness (8), feature records (5) and classification data (5). It is not a code, security or performance test, or a Google score. A link does not establish tested functionality.

What to verify for this project

Repository update recorded
2025-01-23
Screenshot last checked
2026-09-30

A demo link is listed. Check it with your own content and viewport sizes; its presence does not confirm that forms, authentication or payments work.

The catalog identifies Next.js as the primary stack. Check the actual dependency manifest and lockfile for versions and hosting requirements. These notes use recorded metadata, not a code audit or a deployment test.

Use a selection guide →

How this description was prepared

AI-assisted description based on catalog records and repository material. Repository authors are not automatically the reviewers of this description.

Automatically checked against source and license rules; no manual editorial review.

Inspect the recorded source material

SHA-256: 4e7f62b4b448c2b066234328426dd0abb6ef2521d41da9024e900df626ae6a04

2026-09-30T08:11:21.186Z

Source file / repository
# 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

- [Next.js](https://nextjs.org)
- [Lucia](https://lucia-auth.com/)
- [tRPC](https://trpc.io)
- [Drizzle ORM](https://orm.drizzle.team/)
- [PostgreSQL](https://www.postgresql.org/)
- [Stripe](https://stripe.com/)
- [Tailwind CSS](https://tailwindcss.com)
- [Shadcn UI](https://ui.shadcn.com/)
- [React Hook Form](https://www.react-hook-form.com/)
- [React Email](https://react.email/)
- [Playwright](https://playwright.dev/)

## 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](https://playwright.dev/) (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
- [x] 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.
Report a correction

Explore similar templates

Compare previews and descriptions within the same stack and category.