Turn your website leads into paying customers, fast. Our AI bot scrapes every B2B lead you pull from your website so that you know exactly who your potential customers are. Stop leaving money on the table.
When deploying this template, the sequence of steps is important. Follow the steps below in order to get up and running.
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
and set it to the same URL. Make sure to deselect preview and development environments to make sure that preview branches and local development work correctly.
[Optional] - Set up redirect wildcards for deploy previews (not needed if you installed via the Deploy Button)
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/**
. 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 page.
[Maybe Optional] - Set up Supabase environment variables (not needed if you installed via the Deploy Button)
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
and SUPABASE_SERVICE_ROLE_KEY
fields, and copy the project URL and paste to Vercel as 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.
We need to create a webhook in the Developers
section of Stripe. Pictured in the architecture diagram above, this webhook is the piece that connects Stripe to your Vercel Serverless Functions.
- Click the "Add Endpoint" button on the test Endpoints page.
- Enter your production deployment URL followed by
/api/webhooks
for the endpoint URL. (e.g.https://your-deployment-url.vercel.app/api/webhooks
) - Click
Select events
under theSelect events to listen to
heading. - Click
Select all events
in theSelect events to send
section. - Copy
Signing secret
as we'll need that in the next step. - In addition to the
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
and theSTRIPE_SECRET_KEY
we've set earlier during deployment, we need to add the webhook secret asSTRIPE_WEBHOOK_SECRET
env var.
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.
Your 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.:
- Product 1: Hobby
- Price 1: 10 USD per month
- Price 2: 100 USD per year
- Product 2: Freelancer
- Price 1: 20 USD per month
- Price 2: 200 USD per year
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
command executes a series of API requests defined in this JSON file. Simply run stripe fixtures fixtures/stripe-fixtures.json
.
Important: Make sure that you've configured your Stripe webhook correctly and redeployed with all needed environment variables.
- Set your custom branding in the settings
- Configure the Customer Portal settings
- Toggle on "Allow customers to update their payment methods"
- Toggle on "Allow customers to update subscriptions"
- Toggle on "Allow customers to cancel subscriptions"
- Add the products and prices that you want
- Set up the required business information and links
I 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.
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
).
Install the Stripe CLI and link your Stripe account.
Next, start local 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.
In a separate terminal, run the following commands to install dependencies and start the development server:
npm install
npm run dev
# or
yarn
yarn 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.
This template mirrors completed Stripe transactions to the Supabase database. This means that if the Supabase database is unavailable, the Stripe transaction will still succeed, but the Supabase database will not be updated, and the application will pass an error code back to Stripe. By default, Stripe will retry sending its response to the webhook for up to three days, or until the database update succeeds. This means that the Stripe transaction will eventually be reflected in the Supabase database as long as the database comes back online within three days. You may want to implement a process to automatically reconcile the Supabase database with Stripe in case of a prolonged outage.
ngrok http 3000