Usage-based billing template with included amounts and overage at period end. Two plans (Starter, Pro) tracking API calls, storage, and email sends. Overage for usage above included limits is charged at the end of each billing period.
Stack: Next.js 16, Better Auth, Drizzle ORM, PostgreSQL, Commet SDK
Quick Start
commet create my-app -t metered
cd my-app
pnpm install
pnpm devWhat's Included
- Two plans with monthly and yearly prices
- Three metered features: API Calls, Storage, Email Sends
- Included usage per plan with overage billing
- Usage tracking via Commet SDK
- Usage overview dashboard showing current vs included
- Customer billing portal
- Pricing page with included amounts
Key Files
lib/auth/auth.ts— Better Auth + Commet plugin with usage modulelib/payments/commet.ts— Checkout session creationapp/(dashboard)/dashboard/page.tsx— Usage overview with current vs includedapp/pricing/page.tsx— Dynamic pricing with included amountsapp/api/commet/portal/route.ts— Customer portal redirect
Learn More
- Consumption Models — Metered model details
- Track Usage
- Customer Portal
