Balance-based billing template with fixed unit prices. Customers prepay a balance and usage deducts real dollars per action. Two plans (Starter, Pro) with different balances. Features have fixed per-unit costs (API calls, image processing).
Stack: Next.js 16, Better Auth, Drizzle ORM, PostgreSQL, Commet SDK
Quick Start
commet create my-app -t balance-fixed
cd my-app
pnpm install
pnpm devWhat's Included
- Two plans with different starting balances ($25, $75)
- Two features with fixed unit prices (API Call, Image Processing)
- Balance deduction per usage at fixed rates
- Block on exhaustion — usage stops when balance runs out
- Interactive usage demo on dashboard
- Customer billing portal with top-up support
- Pricing page with balance amounts
Key Files
lib/auth/auth.ts— Better Auth + Commet plugin with usage modulelib/payments/commet.ts— Checkout session creationapp/(dashboard)/dashboard/page.tsx— Balance overview with usage simulationapp/pricing/page.tsx— Dynamic pricing pageapp/api/commet/portal/route.ts— Customer portal redirect
Learn More
- Consumption Models — Balance model details
- Track Usage
- Customer Portal
