Live demo of the Whirlwind template, as shippedStripe test mode: card 4242 4242 4242 4242, any future date, any CVCGet Whirlwind →

Customer Portal

Letting users manage subscriptions via Stripe's portal.

Customer portal

Signed-in users with a Stripe customer ID can open Stripe's hosted portal to change plan, update a card or download invoices. The route is /api/stripe/create-portal; the dashboard has the button.
// app/api/stripe/create-portal/route.js (abridged)
const session = await stripe.billingPortal.sessions.create({
  customer: user.stripe_customer_id,
  return_url: `${process.env.NEXT_PUBLIC_APP_URL}/dashboard`,
});
return NextResponse.json({ url: session.url });

Configure it in Stripe

Stripe dashboard → Settings → Billing → Customer portal. Choose what customers may do: cancel, switch plans, see invoice history. The portal must be saved once in test mode and once in live mode.