BoilerplateHub

Next.js + Neon + Better Auth + Stripe

Next.js with Neon, Better Auth and Stripe is a Postgres stack built around branching. Every pull request can get a database copy where auth tables and Stripe state are migrated and exercised together. It suits a small team with review discipline shipping a subscription product they expect to keep changing.

Next.js NeonBetter AuthStripe

Database

Neon

Neon is plain Postgres with branching, which changes the workflow more than it changes the code. Better Auth's migrations and your Stripe tables run against a branch per preview deployment, so a schema change and a webhook change are reviewable side by side against a realistic copy. Use the serverless driver from route handlers, or a pooled connection if you keep a long-lived process, and expect compute waking from idle to slow the first login of the morning.

Authentication

Better Auth

Better Auth stores sessions in Neon, which makes the branching story consistent: a preview environment has its own accounts instead of borrowing production ones. The library's CLI generates schema, so auth tables travel through the same migration review as the rest of the codebase. With Stripe present, the customer ID and subscription rows sit beside the user table and one query answers both who this is and what they are allowed to do.

Payments

Stripe

Stripe is why the schema carries real billing weight here. Prices, subscription items, period boundaries and cancellation flags all land in Neon and your code reads them, because no reseller is holding that state on your behalf. Replaying test-mode events into a branch database is an unusually good way to develop billing changes, since you can corrupt subscription state repeatedly without going near the data paying customers depend on.

What to watch out for

Branching makes databases cheap to create and easy to lose track of, and a webhook endpoint only points at one of them. Test events delivered into a branch that was already deleted, or production events arriving while you believed you were on a branch, both present as nothing happening at all. Pin the destination per environment explicitly and treat branch cleanup as part of merging rather than a task for later.

Boilerplates close to this stack

Matched on Next.js plus the parts of this stack our catalog tags. Each card shows which pieces actually line up, so you can see how much you would still wire yourself.

A CLAUDE.md for this stack

The rules that matter for this combination specifically, including who owns entitlement state. Adapt the commands to your repository before committing it.

CLAUDE.md
# CLAUDE.md

This project is a Next.js SaaS on Neon, Better Auth and Stripe.

## Stack

- Framework: Next.js
- Database: Neon
- Auth: Better Auth
- Payments: Stripe

## Boundaries

- Never edit a migration that has already run. Write a new one.
- Never hardcode Stripe price or product identifiers in components. They belong in config.
- Never trust a client-supplied user id. Read the session from Better Auth on the server.
- Treat webhook handlers as idempotent. The same event will arrive twice.

## Entitlements

- Stripe is the source of truth for what a customer paid for.
- The database mirrors that state; it never decides it.
- Any check for "can this user do X" reads the mirrored entitlement, not a live API call.

## Before you say a change is done

- The app builds.
- Tests pass.
- No secret, key or webhook signing secret appears in a committed file.

Related stacks