Menu

Implementing Usage-Based Billing with Stripe Billing Meters, Next.js 15, and Supabase
📰

Implementing Usage-Based Billing with Stripe Billing Meters, Next.js 15, and Supabase

DEV Community: nextjs·Corsicaa·1 day ago
#RwKbmt5j
#devtonextjs#devto#dev#stripe#supabase
Long article (1044 words) — no AI summary yet.
Reading 0:00
15s threshold

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.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.