Billing & Subscriptions

NextGenKit includes a complete Stripe billing integration with plan gating.

Plans

Plans are defined in lib/billing/plans.ts. The default setup includes:

  • Free — Default for all new organizations
  • Pro — Monthly and annual pricing
  • Business — Monthly and annual pricing

Creating a Checkout Session

import { createCheckoutSession } from "@/server/actions/billing"

// Redirects user to Stripe Checkout
await createCheckoutSession({ priceId: "price_xxx" })

Plan Gating

Restrict features based on the active subscription:

import { requirePlan } from "@/lib/billing/gate"

// Throws with upgrade prompt if not on required plan
await requirePlan("pro")

Customer Portal

Users manage their subscription (upgrade, downgrade, cancel) via Stripe's hosted portal:

import { createPortalSession } from "@/server/actions/billing"

await createPortalSession()

Webhook Sync

Stripe webhooks at app/api/webhooks/stripe/route.ts keep your database in sync:

  • checkout.session.completed — Activates subscription
  • customer.subscription.updated — Syncs plan changes
  • customer.subscription.deleted — Marks as cancelled
  • invoice.payment_failed — Triggers failed payment email