Credit-based billing template where customers receive credits with their plan and spend them on different actions. Two plans (Starter, Pro) with three features consuming different credit amounts. Blocked when credits run out, with credit pack top-ups.
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
