Prerequisites
Before you begin, make sure you have the following:- Node.js 20 or later — the app uses React Router v7, which requires Node 20+
- A Stripe account — sign up at stripe.com if you don’t have one
- Stripe CLI — used to forward webhooks to your local server during development
Setup
Set environment variables
Create a You can find your API keys in the Stripe Dashboard under Developers → API keys.
.env file in the project root and set your Stripe secret key:.env
Start the Stripe CLI webhook listener
In a separate terminal, authenticate the Stripe CLI and forward webhook events to your local server:The CLI will print a webhook signing secret that starts with
whsec_. Copy this value — you will need it in your configuration.Keep this terminal running while you develop. The CLI forwards Stripe billing events (such as
invoice.paid and invoice.payment_failed) to your local app.Run the development server
Start the app:The app runs at http://localhost:5173. The dev server supports hot module replacement, so changes to your files are reflected instantly.
User flow walkthrough
Once the app is running, follow this flow to test the full subscription experience:Register an account
The home route (
/) redirects automatically to /register. Enter your email address to create a Stripe customer account. No password is required — the app uses a session cookie to keep you logged in.Choose a plan
After registration you are redirected to
/prices, which lists the available subscription plans fetched from your Stripe account. Each plan shows its name, price, and billing interval.If no plans appear, make sure you have created products and prices in your Stripe Dashboard. The app reads prices directly from the Stripe API using your secret key.
Subscribe
Select a plan to proceed to
Use any future expiry date, any 3-digit CVC, and any billing postal code.
/subscribe. The subscribe page renders a Stripe Elements card form (CardElement). Enter a test card number to complete the subscription:| Card number | Scenario |
|---|---|
4242 4242 4242 4242 | Successful payment, no authentication required |
4000 0025 0000 3155 | Requires SCA (3D Secure) authentication |
Available scripts
| Script | Command | Description |
|---|---|---|
| Development server | npm run dev | Starts the React Router dev server with HMR at localhost:5173 |
| Production build | npm run build | Compiles the app to ./build/ |
| Production server | npm run start | Serves the production build using react-router-serve |
Next steps
Configuration
Review all environment variables, session settings, and Stripe webhook configuration.
Registration
Learn how user accounts are created and stored in the session.
Plans
Understand how subscription plans are fetched from the Stripe API.
Webhooks
See how the app handles Stripe webhook events to activate subscriptions.