Next.js SaaS template for products that sell actions priced in credits — image, text, voice. Customers receive credits included with their plan and spend them at a different rate per action.
Two plans (Starter, Pro) with three features consuming different credit amounts. When credits run out, usage is blocked until the customer tops up with a credit pack.
Stack: Next.js 16, Better Auth, Drizzle ORM, PostgreSQL, Commet SDK
Quick Start
commet create my-app -t credits
cd my-app
pnpm install
pnpm devWhat's Included
- Two plans with included credits (500 and 2,500)
- Three features with different credit costs (Image=10, Text=2, Voice=25)
- Block on exhaustion — usage stops when credits run out
- Credit pack purchases via customer portal
- Credit balance overview on dashboard
- Customer billing portal with top-up support
- Pricing page with credit amounts
Key Files
lib/auth/auth.ts— Better Auth + Commet plugin with usage modulelib/payments/commet.ts— Checkout session creationapp/(dashboard)/dashboard/page.tsx— Credit balance and cost-per-action overviewapp/pricing/page.tsx— Dynamic pricing with credit amountsapp/api/commet/portal/route.ts— Customer portal redirect
Learn More
- Consumption Models — Credits model details
- Credit Packs
- Customer Portal
Run commet create my-app -t credits to start from this template, or browse the source on GitHub.
