The all-in-one starter kit for high-performance SaaS applications.
For auth redirects (magic links, OAuth providers) to work correctly in deploy previews, navigate to the auth settings (i.e. https://app.supabase.com/project/:project-id/auth/url-configuration
) and add the following wildcard URL to "Redirect URLs": https://**vercel.app/*/*
.
You can read more about redirect wildcard patterns in the docs.
You can use third-party login providers like GitHub or Google. Refer to the docs to learn how to configure these. Once configured you can add them to the provider
array of the Auth
component on the signin.tsx
page.
To start developing your SaaS application, we'll need to configure Stripe to handle test payments. For the following steps, make sure you have the "Test Mode" toggle switched on.
We need to configure the webhook pictured in the architecture diagram above. This webhook is the piece that connects Stripe to your Vercel Serverless Functions.
https://your-deployment-url.vercel.app/api/webhooks
.Select events
under the Select events to listen to
heading.Select all events
in the Select events to send
section.Signing secret
as we'll need that in the next step.To securely interact with Stripe, we need to add a few Environment Variables in the Vercel dashboard.
PUBLIC_STRIPE_PUBLISHABLE_KEY
STRIPE_SECRET_KEY
STRIPE_WEBHOOK_SECRET_LIVE
You can find the first two keys on the API keys tab in Stripe. The STRIPE_WEBHOOK_SECRET_LIVE
is the Signing secret
copied in the previous webhook configuration step.
We need to redeploy the application so that the latest environment variables are present.
Redeploy your application by going to the deployments tab, finding your deployment, and clicking "redeploy."
For Stripe to automatically bill your users for recurring payments, you need to create your product and pricing information in the Stripe Dashboard. When you create or update your product and price information, the changes automatically sync with your Supabase database.
Stripe Checkout currently supports pricing that bills a predefined amount at a specific interval. More complex plans (e.g., different pricing tiers or seats) are not yet supported.
For example, you can create business models with different pricing tiers, e.g.:
The Stripe CLI fixtures
command executes a series of API requests defined in a JSON file. To speed up the setup, we have added a fixtures file to bootstrap test product and pricing data in your Stripe account. Simply run stripe fixtures fixtures/stripe-fixtures.json
.
Important: Be sure to start the webhook forwarding (see below) so that the products created by the fixtures command above are imported into your database.
You can use the Supabase CLI to generate types from your Database by running
supabase gen types typescript --db-url "postgresql://postgres:[YOUR-PASSWORD]@db.[YOUR-PROJECT-REF].supabase.co:5432/postgres" > types_db.ts
That's it. Now you're ready to earn recurring revenue from your customers 🥳
Archive all test mode Stripe products before going live. Before creating your live mode products, make sure to follow the steps below to set up your live mode env vars and webhooks.
To run the project in live mode and process payments with Stripe, modify the environment variables from Stripe "test mode" to "production mode." After switching the variables, be sure to redeploy the application.
To verify you are running in production mode, test checking out with the Stripe test card. The test card should not work.
Afterward, you will need to rebuild your production deployment for the changes to take effect. Within your project Dashboard, navigate to the "Deployments" tab, select the most recent deployment, click the overflow menu button (next to the "Visit" button) and select "Redeploy."
Deploying with Vercel will create a repository for you, which you can clone to your local machine.
Next, use the Vercel CLI to link your project:
vercel login
vercel link
Use the Vercel CLI to download the development env vars:
vercel env pull .env.local
Running this command will create a new .env.local
file in your project folder. For security purposes, you will need to set the SUPABASE_SERVICE_ROLE_KEY
manually from your Supabase dashboard (Settings > API). Lastly, the webhook secret differs for local testing vs. when deployed to Vercel. Follow the instructions below to get the corresponding webhook secret.
First install the CLI and link your Stripe account.
Next, start the webhook forwarding:
stripe listen --forward-to=localhost:3000/api/webhooks
Running this Stripe command will print a webhook secret (such as, whsec_***
) to the console. Set STRIPE_WEBHOOK_SECRET
to this value in your .env.local
file.
npm install
npm run dev
# or
yarn
yarn dev
# or
pnpm install
pnpm dev