Build guides
Step-by-step walkthroughs for shipping real features with @buildbase/sdk.
35 posts · page 3 of 3
How to enforce quotas server-side in Next.js
The record call is the lock, not the if-statement after it. How quota enforcement actually behaves on hard-cap and overage plans.
How to add a credits wallet in Next.js, and why the balance is not one number
Add a credits wallet in Next.js: sell packages, show the balance, spend FIFO from dated buckets, and warn before expiry. The balance is an aggregate over buckets, not a column you decrement.
How to change pricing without affecting existing customers in Next.js
Change SaaS pricing without affecting existing customers: publish a new plan version, leave subscriptions pinned to the old one, and decide what a v1 customer sees when you ship v3.
An annual and monthly toggle in Next.js, and why it is not a boolean
How to add an annual and monthly toggle in Next.js: why the display interval is not the billing interval, what happens to plan allowances, and where the savings percentage should come from.
Proration on plan change in Next.js, and why a downgrade needs the opposite setting
Proration on plan change in Next.js: why upgrades and downgrades need opposite proration behavior, and how to read direction without mistaking a yearly plan for a bigger one.
How to add a free trial without a card in Next.js
A free trial with no credit card in Next.js: turn the card requirement off on the plan version, then handle the part Stripe cannot - what your app renders, and who the gate lets through.
Charge per credit in Next.js, and why the debit goes last
Charge per credit in Next.js: check the balance before the work, debit after it, return 402 when the balance is empty, and pass an idempotencyKey so a retry is not charged twice.
Charge per seat in Next.js, and handle the moment seats run out
Per-seat billing in Next.js: read seat state, gate the invite button, and branch on why invites are blocked. The three block reasons need three different answers.
Charge per API call in Next.js, with overages billed to Stripe
Meter every call, enforce the quota in the same request, and bill what goes over. The whole loop in one route handler.
Enforcing quotas in React without scattering if-statements
Gate features on remaining quota with conditional components, and warn before the wall rather than at it.
Add multi-tenant workspaces in an afternoon
Workspaces, membership and roles without designing a tenancy model from scratch or bolting one on later.