Flat monthly subscriptions work for simple SaaS apps, but API-heavy products, AI tools, and data pipelines incur variable infrastructure costs. Charging per unit consumed API calls, generated reports, or synced records aligns your revenue with your actual server bill.
Stripe replaced its legacy subscription usage records with Billing Meters . Below is a complete implementation using Next.js 15 Route Handlers, Supabase (PostgreSQL), and Stripe Billing Meters.
1. Create the Billing Meter and Price in Stripe
In the Stripe Dashboard (or via the API), create a meter with an event name for example, api_request_completed and set the aggregation formula to sum .
Next, create a recurring price attached to that meter ( usage_type: 'metered' ). Save the resulting price_... ID in your environment variables as STRIPE_METERED_PRICE_ID .
2. Store Customer Mapping and Local Usage Logs in Supabase
Never rely exclusively on Stripe to display usage dashboards to your users.…