Next.js SaaS template for API products that charge fixed unit prices against a prepaid balance. Customers load a dollar balance and every action deducts real dollars at the price you set.
Two plans (Starter, Pro) with different starting balances. Two features with fixed per-unit costs: API calls and 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
Run commet create my-app -t balance-fixed to start from this template, or browse the source on GitHub.
