File Locations
- Main Component:
src/components/marketing/pricing.tsx(Handles all logic and UI) - Page Route:
src/app/(marketing)/pricing/page.tsx(Renders the component and other sections)
How to Customize Pricing Plans
All pricing plans are managed in theplans array at the top of the file. By modifying the objects in this array, you can change the content of each pricing card.
Understanding the plans Array
Each object in the array represents a single pricing card and has the following properties, in order:
The name of the plan (e.g., “Pro”, “Enterprise”).
The price per month to display on the UI. Set to
null for plans without a fixed price (like Enterprise).The price per month when billed annually to display on the UI. Set to
null for plans without a fixed price.The Stripe Price ID for the monthly subscription. This is sent to your backend for checkout. Set to
null for non-purchasable plans (like Free or Enterprise).The Stripe Price ID for the yearly subscription. Set to
null for non-purchasable plans.A short description of the plan shown below the price.
A short text displayed above the features list (e.g., “Everything in Pro +”).
An array of strings, where each string is a feature listed on the card.
If
true, a “Popular” badge is displayed on the card, and the button uses the primary color.The text displayed on the main call-to-action button.
Set to
true for the free plan. This makes the button redirect to the sign-up page instead of initiating a Stripe checkout.Set to
true for enterprise-style plans. This displays the price as “Custom” and makes the button open an email client to contact sales.Example: Modifying a Plan
To change a plan, simply find its object in theplans array and edit the properties.
src/components/marketing/pricing.tsx
Connecting Buttons to Stripe
This section focuses on connecting buttons for recurring subscriptions. For a full guide on backend setup (APIs, webhooks) and implementing one-time payments, please see the main Payments with Stripe documentation.
1
Store your Price IDs in .env.local
It is highly recommended to store your Price IDs in an environment file (
.env.local) with the NEXT_PUBLIC_ prefix. This keeps your configuration separate from your code..env.local
2
Connect Price IDs in the Component
In
pricing.tsx, use process.env to assign these IDs to the plans array.src/components/marketing/pricing.tsx
How the submission logic works
How the submission logic works
When a user clicks a purchase button, the
handleSubmit function runs the following logic:- Checks for special plans: It first checks if the plan is “Free” or “Contact Us” and handles them separately (e.g., redirecting to sign-up or opening an email client).
- Checks user authentication: For paid plans, it uses Supabase to check if the user is logged in.
- If the user is not logged in, they are redirected to the
/sign-inpage. After signing in, they will be returned to the pricing page to complete the purchase. - If the user is logged in, it proceeds to the next step.
- If the user is not logged in, they are redirected to the
- Initiates checkout: It sends the selected
price_idto the/api/checkout_sessionsAPI route, which then redirects the user to a Stripe Checkout page to complete the payment.
Customizing UI Elements
1
Billing Cycle Toggle
The discount badge for the yearly plan can be customized directly in the JSX. You can change the discount percentage or the text.
src/components/marketing/pricing.tsx
2
`Contact Sales` Email
For the Enterprise plan, the “Contact Sales” button opens a
mailto: link. You can change the recipient email and subject line inside the handleSubmit function.src/components/marketing/pricing.tsx