SaaS
Features

Payments

Stripe integration for subscription billing — checkout sessions, customer portal, webhooks, and full subscription lifecycle management.

What's Included

  • Checkout — Stripe Checkout sessions with trial periods and promotion codes
  • Customer Portal — self-serve billing management (upgrade, cancel, update payment method)
  • Webhooks — automatic subscription status sync (active, canceled, unpaid)
  • Pricing Page — server-rendered prices pulled from Stripe in real time
  • Subscription Management — database schema tracks plan, status, and Stripe IDs

Pricing Page

The pricing page at /pricing fetches products and prices directly from Stripe. Products named Base and Plusare displayed in gradient-ring cards with checkout buttons. If Stripe isn't configured, fallback default pricing is shown.

Checkout Flow

  1. User clicks a plan on the pricing page
  2. Browser POSTs to a server action with the priceId
  3. Server creates a Stripe Checkout session with trial and return URLs
  4. User is redirected to Stripe's hosted checkout page
  5. After payment, Stripe redirects back to /api/stripe/checkout
  6. The success handler creates the team and sets the session cookie

Webhook Events Handled

EventAction
customer.subscription.updatedUpdates plan, status, and product ID in the database
customer.subscription.deletedClears subscription fields (downgrade to free)
Stripe CLI for local testing

Install the Stripe CLI and run stripe listen --forward-to localhost:3000/api/stripe/webhook to forward webhook events to your local dev server.

Next.js SaaS Starter — Launch your SaaS