Skip to main content
A limit needs two checks: the real one on your backend, and one in your UI so the customer isn’t surprised.

Check on your backend

Decide what a denial looks like. For an API route, a 403 with a reason your frontend can act on. For a page, a redirect to your pricing page. When the action is the thing you count, use consume() instead. It checks and counts in one step, so a burst of requests can’t all slip past the limit:
consume() needs the customer to exist in Kerne. People who signed up through Kerne do, and a first checkout creates one. Otherwise, call kerne.customers.upsert() once.

Show it in your UI

<Access> checks for the signed-in user and handles loading. It hides things, it doesn’t protect them: anyone can edit a page, so the backend check is the one that counts. Disable a control before someone hits the limit, not after they click:

Stop, or keep serving?

What happens past the allowance is set on each plan, under Past the allowance: Stop, Keep free or Bill it. Your code stays the same. Stop suits what a customer should decide to buy more of: seats, storage, expensive infrastructure. Bill it suits usage-shaped things, like email sends or bandwidth, where blocking angers a customer without protecting anything. See Design your pricing. A spending cap stops the billing, never the service. To stop usage, set a ceiling in units: see why the cap doesn’t block.

Don’t lose the user’s work

Someone who spends 30 minutes on a report and gets blocked on Save doesn’t file a ticket: they leave. “Draft saved. Upgrade to publish” keeps their work, “Error: storage limit reached” throws it away. Check before the expensive step starts, not only when they submit.