A Next.js 16 starter kit with the three parts that always eat the first month: authentication, billing that meters actual AI usage, and a streaming Claude endpoint that doesn't fall over. Read the code, change what you want, keep it forever.
The boring 30% of an AI SaaS takes 80% of the time
Auth, Stripe, webhooks, and metering are solved problems — but only in the sense that everyone solves them again, badly, at the start of every project. Usage-based billing for AI is worse: you have to charge for tokens you only know about after the response has streamed, and you must not charge twice when Stripe retries a webhook.
This kit is that layer, already written and already QC'd: 32 source files, typechecked, linted, built, and smoke-tested before release.
What's inside
The parts you'd otherwise write twice
Auth.js (v5) — Google sign-in, sessions, protected routes, the dashboard shell already wired up.
Usage-based metering — Stripe Billing Meters, charged on real token counts after each response streams, rounded so you never sell at a loss.
Claude API streaming — a chat route that streams properly in the App Router, with the error paths handled.
DEMO_MODE — one env flag turns the app into a safe public demo: cheap model, capped tokens, per-visitor daily limit via signed cookie, checkout replaced by an explanation. No database needed.
Docs that match the code — setup, env vars, and the deployment path that was actually used to put the demo online.
Metering AI usage without losing money or double-charging
// after the stream finishes, not before
const { input_tokens, output_tokens } = usage;
const cost = ceilToCredit(
input_tokens * MODEL.inPrice +
output_tokens * MODEL.outPrice
);
await meter.record(customerId, cost); // Stripe Billing Meter
// webhook retries can't double-count:
// stripeCheckoutSessionId is a unique key on the ledger
Two failure modes that cost real money — charging before you know the token count, and Stripe retrying a webhook — are handled in the code you're buying, not left as an exercise.
Fit
Who this is for — and who it isn't
A good fit if
You're starting an AI product on Next.js, you want subscriptions plus usage billing, and you'd rather read 32 files you own than adopt a framework that owns you.
Not a good fit if
You need multi-tenant teams, RBAC, an admin panel and a marketing site out of the box — the bigger boilerplates at $200–350 do more, and this one deliberately does less, for less.
Details
Before you buy
Can I try it first?
Yes — demo.duonglabs.com runs the exact code you get, in DEMO_MODE. Sign-in is allowlisted while Google verification is pending: email me and I'll add your address, usually the same day.
What's the license?
Use it in unlimited projects of your own, commercial included. You can't resell or redistribute the kit itself.
Updates?
Free for buyers, pushed to the same download link, with an email when there's a new version.
What do I still need to set up?
Your own Stripe account, Google OAuth client, and Anthropic API key — the kit wires them together, the accounts are yours.
Refunds and invoices?
Handled by Lemon Squeezy as merchant of record. If something's wrong, email me first — I'd rather fix it than take the refund.
Get the kit
One-time $149. Instant download, full source, yours to keep.