The all-in-one subscription starter kit for high-performance SaaS applications, powered by Stripe, Supabase, and Vercel.
[!WARNING] This repo has been sunset and replaced by a new template: https://github.com/nextjs/saas-starter
When deploying this template, the sequence of steps is important. Follow the steps below in order to get up and running.
The Vercel Deployment will create a new repository with this template on your GitHub account and guide you through a new Supabase project creation. The Supabase Vercel Deploy Integration will set up the necessary Supabase environment variables and run the SQL migrations to set up the Database schema on your account. You can inspect the created tables in your project's Table editor.
Should the automatic setup fail, please create a Supabase account, and a new project if needed. In your project, navigate to the SQL editor and select the "Stripe Subscriptions" starter template from the Quick start section.
Follow this guide to set up an OAuth app with GitHub and configure Supabase to use it as an auth provider.
In your Supabase project, navigate to auth > URL configuration and set your main production URL (e.g. https://your-deployment-url.vercel.app) as the site url.
Next, in your Vercel deployment settings, add a new Production environment variable called
NEXT_PUBLIC_SITE_URL
If you've deployed this template via the "Deploy to Vercel" button above, you can skip this step. The Supabase Vercel Integration will have set redirect wildcards for you. You can check this by going to your Supabase auth settings and you should see a list of redirects under "Redirect URLs".
Otherwise, for auth redirects (email confirmations, magic links, OAuth providers) to work correctly in deploy previews, navigate to the auth settings and add the following wildcard URL to "Redirect URLs":
https://*-username.vercel.app/**
If you've deployed this template via the "Deploy to Vercel" button above, you can skip this step. The Supabase Vercel Integration will have run database migrations for you. You can check this by going to the Table Editor for your Supabase project, and confirming there are tables with seed data.
Otherwise, navigate to the SQL Editor, paste the contents of the Supabase
If you've deployed this template via the "Deploy to Vercel" button above, you can skip this step. The Supabase Vercel Integration will have set your environment variables for you. You can check this by going to your Vercel project settings, and clicking on 'Environment variables', there will be a list of environment variables with the Supabase icon displayed next to them.
Otherwise navigate to the API settings and paste them into the Vercel deployment interface. Copy project API keys and paste into the
NEXT_PUBLIC_SUPABASE_ANON_KEY
SUPABASE_SERVICE_ROLE_KEY
NEXT_PUBLIC_SUPABASE_URL
Congrats, this completes the Supabase setup, almost there!
Next, we'll need to configure Stripe to handle test payments. If you don't already have a Stripe account, create one now.
For the following steps, make sure you have the "Test Mode" toggle switched on.
Create a WebhookWe need to create a webhook in the
Developers
/api/webhooks
https://your-deployment-url.vercel.app/api/webhooks
Select events
Select events to listen to
Select all events
Select events to send
Signing secret
whsec_xxx
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
STRIPE_SECRET_KEY
STRIPE_WEBHOOK_SECRET
For the newly set environment variables to take effect and everything to work together correctly, we need to redeploy our app in Vercel. In your Vercel Dashboard, navigate to deployments, click the overflow menu button and select "Redeploy" (do NOT enable the "Use existing Build Cache" option). Once Vercel has rebuilt and redeployed your app, you're ready to set up your products and prices.
Create product and pricing informationYour application's webhook listens for product updates on Stripe and automatically propagates them to your Supabase database. So with your webhook listener running, you can now create your product and pricing information in the Stripe Dashboard.
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.:
Optionally, to speed up the setup, we have added a fixtures file to bootstrap test product and pricing data in your Stripe account. The Stripe CLI
fixtures
stripe fixtures fixtures/stripe-fixtures.json
Important: Make sure that you've configured your Stripe webhook correctly and redeployed with all needed environment variables.
Configure the Stripe customer portalI know, that was quite a lot to get through, but it's worth it. You're now ready to earn recurring revenue from your customers. 🥳
If you haven't already done so, clone your Github repository to your local machine.
Ensure you have pnpm installed and run:
pnpm install
Next, use the Vercel CLI to link your project:
pnpm dlx vercel loginpnpm dlx vercel link
pnpm dlx
pnpm dlx
If you don't intend to use a local Supabase instance for development and testing, you can use the Vercel CLI to download the development env vars:
pnpm dlx vercel env pull .env.local
Running this command will create a new
.env.local
SUPABASE_SERVICE_ROLE_KEY
Settings > API
--local
--linked' or '--project-id <string>' in the
script in
It's highly recommended to use a local Supabase instance for development and testing. We have provided a set of custom commands for this in
package.json
First, you will need to install Docker. You should also copy or rename:
.env.local.example
.env.local
.env.example
.env
Next, run the following command to start a local Supabase instance and run the migrations to set up the database schema:
pnpm supabase:start
The terminal output will provide you with URLs to access the different services within the Supabase stack. The Supabase Studio is where you can make changes to your local database instance.
Copy the value for the
service_role_key
SUPABASE_SERVICE_ROLE_KEY
.env.local
You can print out these URLs at any time with the following command:
pnpm supabase:status
To link your local Supabase instance to your project, run the following command, navigate to the Supabase project you created above, and enter your database password.
pnpm supabase:link
If you need to reset your database password, head over to your database settings and click "Reset database password", and this time copy it across to a password manager! 😄
🚧 Warning: This links our Local Development instance to the project we are using for
production
preview
staging
production
Once you've linked your project, you can pull down any schema changes you made in your remote database with:
pnpm supabase:pull
You can seed your local database with any data you added in your remote database with:
pnpm supabase:generate-seedpnpm supabase:reset
🚧 Warning: this is seeding data from the
production
preview
staging
You can make changes to the database schema in your local Supabase Studio and run the following command to generate TypeScript types to match your schema:
pnpm supabase:generate-types
You can also automatically generate a migration file with all the changes you've made to your local database schema with the following command:
pnpm supabase:generate-migration
And push those changes to your remote database with:
pnpm supabase:push
Remember to test your changes thoroughly in your
local
staging
preview
production
Use the Stripe CLI to login to your Stripe account:
pnpm stripe:login
This will print a URL to navigate to in your browser and provide access to your Stripe account.
Next, start local webhook forwarding:
pnpm stripe:listen
Running this Stripe command will print a webhook secret (such as,
whsec_***
STRIPE_WEBHOOK_SECRET
.env.local
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
STRIPE_SECRET_KEY
.env.local
In a separate terminal, run the following command to start the development server:
pnpm dev
Note that webhook forwarding and the development server must be running concurrently in two separate terminals for the application to work correctly.
Finally, navigate to http://localhost:3000 in your browser to see the application rendered.
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, switch Stripe from "test mode" to "production mode." Your Stripe API keys will be different in production mode, and you will have to create a separate production mode webhook. Copy these values and paste them into Vercel, replacing the test mode values.
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" (do NOT enable the "Use existing Build Cache" option).
To verify you are running in production mode, test checking out with the Stripe test card. The test card should not work.
The all-in-one subscription starter kit for high-performance SaaS applications, powered by Stripe, Supabase, and Vercel.
[!WARNING] This repo has been sunset and replaced by a new template: https://github.com/nextjs/saas-starter
When deploying this template, the sequence of steps is important. Follow the steps below in order to get up and running.
The Vercel Deployment will create a new repository with this template on your GitHub account and guide you through a new Supabase project creation. The Supabase Vercel Deploy Integration will set up the necessary Supabase environment variables and run the SQL migrations to set up the Database schema on your account. You can inspect the created tables in your project's Table editor.
Should the automatic setup fail, please create a Supabase account, and a new project if needed. In your project, navigate to the SQL editor and select the "Stripe Subscriptions" starter template from the Quick start section.
Follow this guide to set up an OAuth app with GitHub and configure Supabase to use it as an auth provider.
In your Supabase project, navigate to auth > URL configuration and set your main production URL (e.g. https://your-deployment-url.vercel.app) as the site url.
Next, in your Vercel deployment settings, add a new Production environment variable called
NEXT_PUBLIC_SITE_URL
If you've deployed this template via the "Deploy to Vercel" button above, you can skip this step. The Supabase Vercel Integration will have set redirect wildcards for you. You can check this by going to your Supabase auth settings and you should see a list of redirects under "Redirect URLs".
Otherwise, for auth redirects (email confirmations, magic links, OAuth providers) to work correctly in deploy previews, navigate to the auth settings and add the following wildcard URL to "Redirect URLs":
https://*-username.vercel.app/**
If you've deployed this template via the "Deploy to Vercel" button above, you can skip this step. The Supabase Vercel Integration will have run database migrations for you. You can check this by going to the Table Editor for your Supabase project, and confirming there are tables with seed data.
Otherwise, navigate to the SQL Editor, paste the contents of the Supabase
If you've deployed this template via the "Deploy to Vercel" button above, you can skip this step. The Supabase Vercel Integration will have set your environment variables for you. You can check this by going to your Vercel project settings, and clicking on 'Environment variables', there will be a list of environment variables with the Supabase icon displayed next to them.
Otherwise navigate to the API settings and paste them into the Vercel deployment interface. Copy project API keys and paste into the
NEXT_PUBLIC_SUPABASE_ANON_KEY
SUPABASE_SERVICE_ROLE_KEY
NEXT_PUBLIC_SUPABASE_URL
Congrats, this completes the Supabase setup, almost there!
Next, we'll need to configure Stripe to handle test payments. If you don't already have a Stripe account, create one now.
For the following steps, make sure you have the "Test Mode" toggle switched on.
Create a WebhookWe need to create a webhook in the
Developers
/api/webhooks
https://your-deployment-url.vercel.app/api/webhooks
Select events
Select events to listen to
Select all events
Select events to send
Signing secret
whsec_xxx
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
STRIPE_SECRET_KEY
STRIPE_WEBHOOK_SECRET
For the newly set environment variables to take effect and everything to work together correctly, we need to redeploy our app in Vercel. In your Vercel Dashboard, navigate to deployments, click the overflow menu button and select "Redeploy" (do NOT enable the "Use existing Build Cache" option). Once Vercel has rebuilt and redeployed your app, you're ready to set up your products and prices.
Create product and pricing informationYour application's webhook listens for product updates on Stripe and automatically propagates them to your Supabase database. So with your webhook listener running, you can now create your product and pricing information in the Stripe Dashboard.
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.:
Optionally, to speed up the setup, we have added a fixtures file to bootstrap test product and pricing data in your Stripe account. The Stripe CLI
fixtures
stripe fixtures fixtures/stripe-fixtures.json
Important: Make sure that you've configured your Stripe webhook correctly and redeployed with all needed environment variables.
Configure the Stripe customer portalI know, that was quite a lot to get through, but it's worth it. You're now ready to earn recurring revenue from your customers. 🥳
If you haven't already done so, clone your Github repository to your local machine.
Ensure you have pnpm installed and run:
pnpm install
Next, use the Vercel CLI to link your project:
pnpm dlx vercel loginpnpm dlx vercel link
pnpm dlx
pnpm dlx
If you don't intend to use a local Supabase instance for development and testing, you can use the Vercel CLI to download the development env vars:
pnpm dlx vercel env pull .env.local
Running this command will create a new
.env.local
SUPABASE_SERVICE_ROLE_KEY
Settings > API
--local
--linked' or '--project-id <string>' in the
script in
It's highly recommended to use a local Supabase instance for development and testing. We have provided a set of custom commands for this in
package.json
First, you will need to install Docker. You should also copy or rename:
.env.local.example
.env.local
.env.example
.env
Next, run the following command to start a local Supabase instance and run the migrations to set up the database schema:
pnpm supabase:start
The terminal output will provide you with URLs to access the different services within the Supabase stack. The Supabase Studio is where you can make changes to your local database instance.
Copy the value for the
service_role_key
SUPABASE_SERVICE_ROLE_KEY
.env.local
You can print out these URLs at any time with the following command:
pnpm supabase:status
To link your local Supabase instance to your project, run the following command, navigate to the Supabase project you created above, and enter your database password.
pnpm supabase:link
If you need to reset your database password, head over to your database settings and click "Reset database password", and this time copy it across to a password manager! 😄
🚧 Warning: This links our Local Development instance to the project we are using for
production
preview
staging
production
Once you've linked your project, you can pull down any schema changes you made in your remote database with:
pnpm supabase:pull
You can seed your local database with any data you added in your remote database with:
pnpm supabase:generate-seedpnpm supabase:reset
🚧 Warning: this is seeding data from the
production
preview
staging
You can make changes to the database schema in your local Supabase Studio and run the following command to generate TypeScript types to match your schema:
pnpm supabase:generate-types
You can also automatically generate a migration file with all the changes you've made to your local database schema with the following command:
pnpm supabase:generate-migration
And push those changes to your remote database with:
pnpm supabase:push
Remember to test your changes thoroughly in your
local
staging
preview
production
Use the Stripe CLI to login to your Stripe account:
pnpm stripe:login
This will print a URL to navigate to in your browser and provide access to your Stripe account.
Next, start local webhook forwarding:
pnpm stripe:listen
Running this Stripe command will print a webhook secret (such as,
whsec_***
STRIPE_WEBHOOK_SECRET
.env.local
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
STRIPE_SECRET_KEY
.env.local
In a separate terminal, run the following command to start the development server:
pnpm dev
Note that webhook forwarding and the development server must be running concurrently in two separate terminals for the application to work correctly.
Finally, navigate to http://localhost:3000 in your browser to see the application rendered.
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, switch Stripe from "test mode" to "production mode." Your Stripe API keys will be different in production mode, and you will have to create a separate production mode webhook. Copy these values and paste them into Vercel, replacing the test mode values.
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" (do NOT enable the "Use existing Build Cache" option).
To verify you are running in production mode, test checking out with the Stripe test card. The test card should not work.