← Back to blog
ComparisonPublished 2026-03-03· 6 min read

Next.js SaaS Boilerplate With Stripe and Auth: 2026 Guide

WangNan, author at Uncorne
Published by Uncorne · Updated 2026-10-16

Searching for a "Next.js SaaS boilerplate with Stripe and auth" sounds like a feature hunt. It is not. You are really asking one question: how much of the commodity sixty percent — sign-up, database, billing, dashboard, deploy — do I still have to write myself? This guide gives you a concrete, ten-minute way to answer that for any starter you are considering, including the one this site ships.

Checklist overview of a Next.js SaaS boilerplate with Stripe and auth
Checklist overview of a Next.js SaaS boilerplate with Stripe and auth

Start with the four non-negotiables

Treat these as pass or fail, not nice-to-haves. If a starter misses any one of them, you will be rebuilding it within a month — usually at the worst possible time, when real customers are already waiting.

| Area | What must already be wired | What to look for in code | | --- | --- | --- | | Auth | Email magic-link plus OAuth, with row-level security on by default | A Supabase Auth integration and RLS policies you can actually read, not a stub | | Billing | Hosted checkout plus a webhook that flips a plan flag in your database | The event is verified, deduplicated, then written — in that order | | Database | Postgres with a seeded schema and a migration history | The initial schema checked into the repo, not a loose SQL dump in a README | | Deploy | A Vercel-ready config and a one-command path to production | Environment variables documented by name, with an example file |

A starter that only has a login form and a Stripe Checkout redirect is a demo. A starter where a verified webhook signature is the single source of truth for entitlements is a business.

Webhook verification is where most templates fail

This is the part worth reading twice. A browser redirect lies: the user closes the tab, the provider retries, a test fires twice. Only a verified webhook should ever change what a customer is entitled to.

The contract we use is deliberately precise:

  • Missing, invalid or malformed signature → throw immediately; the route answers 400.
  • Validly signed event that needs no handling → return an empty list; the route answers 200 with an ignored flag.
  • Already-seen event id → skip before any plan or license write.

Getting this backwards is a security bug, not a style choice. An earlier revision of this codebase treated verification failure as "no events" and answered 200. That meant a forged request looked successful. Never trade a 400 for a quiet 200.

Webhook verification flow showing 400 on bad signatures
Webhook verification flow showing 400 on bad signatures

In the POST /api/webhook route every provider adapter throws on verification failure. An empty array means exactly one thing: the event was validly signed and simply needs no action — for example a checkout.session.completed for a product this app does not sell. Replays are deduplicated by event id in a webhook_events table before anything is written. If you are new to event types, Stripe's webhook event reference is the clearest catalogue to read alongside your provider's own docs.

Idempotency: the bug you meet at your first refund

Providers retry. They have to, because networks are unreliable. A webhook handler that is not idempotent will write the same plan twice, double-count usage, or re-open a subscription a customer already cancelled. The fix is not clever: record the event id, check it first, and make the write itself conditional on the id not existing.

The moment this matters is rarely launch day. It is the first refund, the first duplicate event, the first time a customer questions an invoice. By then, retrofitting idempotency means touching every entitlement path you have already shipped. Build it in before you need it.

A related trap is using the client as evidence. The browser can show a success page while the webhook never arrived. Entitlements must read from the database, which is written only by verified events — never from a query string or a local state flag.

One gateway or five providers?

The default in Uncorne is Waffo Pancake, a Merchant of Record that handles sales tax and VAT for you — the merchant of record model in plain terms. Stripe, Creem, PayPal, Waffo Acquiring and Lemon Squeezy are switchable at generation time, and none is a valid choice if you bring your own billing.

All of them sit behind a single PaymentProvider interface and one POST /api/webhook route. Your application code never branches on which gateway handled the payment. That separation is the whole point: the gateway is a configuration decision, not an architectural one. See our comparison of five gateways for the trade-offs.

Five payment provider adapters behind one webhook contract
Five payment provider adapters behind one webhook contract

A ten-minute evaluation you can actually run

Do not read another feature list. Run the starter.

git clone <the-starter-repository>
cd starter && cp .env.example .env.local
# fill in auth and billing variables, then
npm install && npm run dev

Then try, in order:

  1. Sign up with email and with OAuth. Both should land you in a protected area.
  2. Hit the paywall for a paid feature. You should be stopped on the server, not merely hidden in the UI.
  3. Complete a test checkout. The plan flag in your database should flip without a page refresh.
  4. Fire a webhook with a bad signature. It must return 400, never 200.
  5. Replay the same valid event twice. The second write must be a no-op.

If any step is blocked by code you now have to write, you have found your answer. A good starter makes all five steps boring.

What else belongs in the download

A starter you can ship on should hand you more than a running app. Check what is inside the ZIP you actually receive. Unselected modules should be gone rather than commented out: unused providers, auth backends and feature flags left in the tree become dead code you must audit later. Navigation should be rewritten so no link points to a page that was pruned.

The package should also carry machine-readable instructions for you and your tools. Look for an AGENTS.md that states the repository contract and definition of done, a design guide scoped to the visual style you picked, and editor rules that match. These matter because they keep an AI coding assistant from reintroducing the modules you deliberately removed. See our agent-ready docs guide for why that read order matters.

Finally, check the brand surface. A generator that sells source code must strip its own marketing pages, pricing components and generator internals from the customer download. A leftover reference to someone else's product is not a cosmetic issue — it ships to your users. Eighteen representative build combinations should be downloaded and type-checked in CI, so a pruning rule that breaks one configuration fails before a customer sees it.

Honest limits

No starter is complete. This one has real profile and role endpoints and a billing portal, but the local SQLite fallback is an account directory, not a full auth provider: no MFA, no OAuth, no session rotation. SMTP is not implemented — you plug in a REST mailer or a safe no-op. Server Actions are used where they keep the write path simple.

That honesty is a feature. A template that claims everything usually hides the gaps until you are committed. Pick the one whose gaps you can live with — and whose webhook returns 400 when it should.

About the author: WangNan writes about shipping source-available SaaS at https://www.uncorne.com.

FAQ

What should I check first in a Next.js SaaS boilerplate with Stripe and auth?+

Check webhook verification first. A starter must reject a missing or invalid signature with HTTP 400, deduplicate event ids before writing entitlements, and treat an empty event list only as a validly signed but unhandled event. Everything else is cosmetic by comparison.

Does the boilerplate have to use Stripe?+

No. Stripe is the best-documented processor, but a Merchant of Record such as Waffo Pancake or Lemon Squeezy removes sales-tax handling if you sell globally without a company entity. What matters is a single provider-agnostic checkout and webhook contract.

What does row-level security actually protect here?+

RLS makes the database enforce tenant boundaries even if application code forgets a WHERE clause. In a Supabase-backed starter, auth.uid() policies should exist on user-owned tables from the first migration, not be bolted on later.

Can I evaluate a starter without a payment account?+

Yes. Clone it, set the example env vars, run the dev server, then fire a webhook with a bad signature — it must return 400. You can also replay the same event twice and confirm the second write is a no-op. A real checkout still needs a sandbox account.

All frequently asked questions · Markdown version (for AI agents)