Recipe: Add a pricing plan / tier
Recipe: Add a pricing plan / tier
- Create the Stripe Price(s) in the Stripe dashboard (or via API) for the new tier — monthly and/or annual. Note their ids.
- Add the tier to the
PLANSarray inlib/billing/plans.ts:{ id: "startup", // new PlanId — extend the type too name: "Startup", description: "...", price: { monthly: 99, annual: 990 }, priceId: { monthly: process.env.STRIPE_STARTUP_MONTHLY_PRICE_ID, annual: process.env.STRIPE_STARTUP_ANNUAL_PRICE_ID, }, features: ["...", "..."], } - Widen the
PlanIdunion type at the top oflib/billing/plans.tsto include the new id. - Add the env vars to
.env.example(and your.env) —STRIPE_STARTUP_MONTHLY_PRICE_ID,STRIPE_STARTUP_ANNUAL_PRICE_ID. - That's it —
lib/auth.tsbuilds the Stripe plugin's plan list fromPAID_PLANSautomatically, and both/pricingand/subscriberender from the same array. No other file needs to change. - Verify:
npm run build(confirms the type change compiles), then in the browser check/pricingshows the new card, and test-subscribe to it withstripe listenrunning locally (see billing.md).
To remove a tier, do the reverse: delete its entry from PLANS, remove
its env vars, and archive the Stripe Price in the dashboard (Stripe doesn't
allow deleting Prices, only archiving). Existing subscribers on a removed
plan keep their subscription row — decide separately how you want to
migrate or grandfather them.