Stripe Setup (Billing)

NextGenKit includes Stripe subscriptions, customer portal, and webhook-driven sync out of the box.

1. Create Stripe Products

  1. Go to Stripe Dashboard → Products
  2. Create two products: Pro and Business
  3. For each product, create two prices: Monthly and Annual
  4. Copy the Price IDs to your .env.local

2. Configure Customer Portal

  1. Go to Settings → Billing → Customer Portal
  2. Enable subscription cancellation and plan switching
  3. Save the configuration

3. Set Up Webhooks

  1. Go to Developers → Webhooks
  2. Add endpoint: https://your-domain.com/api/webhooks/stripe
  3. Subscribe to events:
    • checkout.session.completed
    • customer.subscription.updated
    • customer.subscription.deleted
    • invoice.payment_failed
  4. Copy the Signing Secret to STRIPE_WEBHOOK_SECRET

4. Local Webhook Testing

# Install Stripe CLI, then:
pnpm stripe:listen

# This forwards events to localhost:3000/api/webhooks/stripe

Plan Gating

Use requirePlan() from lib/billing/gate.ts to restrict features by plan:

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

// In a server action or route handler:
await requirePlan("pro") // throws if user is on free plan