UsageGate runs in the Next.js server route — never in the browser.
UsageGate is the entitlements layer for your SaaS, with any payment gateway. See how to build a SaaS and payments architecture.
The three calls
import { GateClient } from "@usagegate/sdk";
const gate = new GateClient(process.env.USAGEGATE_KEY!);
// Spend one credit first; only do the work if it succeeded.
const spent = await gate.consume(userId, "ai_credits", 1);
if (!spent.success) {
return Response.json({ error: "Upgrade to keep going" }, { status: 402 });
}Env
USAGEGATE_KEY=gk_live_…Then Get started — plan table, key, Stripe or another gateway.
Also in this stack
Payment gateway: Stripe, Paystack, or Paddle. UsageGate is not the processor.

