-
Supabase for Database, Auth, Storage, and Realtime
-
Stripe for Billing
- Checkout to buy credits for image generation.
- Customer Portal to manage billing and view invoices.
- Webhooks to automatically sync product offerings with database.
-
Next.js App Router
- Server Actions - Image uploads & creating Stripe sessions
- Route Handlers - Supabase Auth, Vercel Cron Jobs, and Webhooks for Replicate, Stripe, and Supabase
- Metadata - File-based & Config-based
- Dynamic Routes - SSR 🚀
- Vercel Cron Jobs - Remove all data and images older than 1 day
-
Use the Deploy with Vercel button above. This will:
- Create a new git repository for the project.
- Set up the necessary Supabase environment variables and run the SQL migrations to set up the Database schema on a new project.
- If for some reason the migrations weren't automatically run by the integration, or you are manually setting up Supabase, you can manually run them in the SQL Editor.
- The integration should have also handled adding the site url and approved redirect urls for auth. But in case it didn't, you manually do so here.
- Set up some environment variables.
-
There are two more things we need to manually set up on Supabase
- We need to create a Database Webhook
- This will trigger the creation of a customer on stripe when a user creates an account.
- Call the webhook "customer", have it trigger from insert and delete on public.users and send an HTTP POST request to
https://[YOUR_DOMAIN_HERE]/api/webhooks/supabase/customer
- The final thing we have to do on Supabase is to enable Google OAuth.
- You can follow the instructions from the official documentation here.
- We need to create a Database Webhook
-
Now, we can configure Stripe
- Edit the webhook url in the stripe webhook.json file to match your domain.
- Run
pnpm fixtures:webhook
. This will set up a webhook to sync products/prices between Stripe & Supabase.
-
Back on Vercel
- Add the
STRIPE_WEBHOOK_SECRET
environment variable. You can find this in your Stripe Webhooks Dashboard underSigning secret
for the specific webhook. - Then add
TUNNEL_URL
env variable and make it an empty string. You will edit this in your.env.local
when developing locally as needed. - If you haven't already added your
REPLICATE_API_TOKEN
env variable, you can do that now as well. - Now redeploy your app on Vercel, and wait for the deployment to complete before moving onto the next step.
- Add the
-
Lastly,
- Run
pnpm fixtures:products
. This will generate the default products/prices on your Stripe account. - You can verify this worked by checking your Stripe Dashboard & the products/prices table on Supabase
- You should be all set to go now!
- Run
- You can use the Stripe CLI to test webhooks locally. More info here.
- You can pull env variables from Vercel using
pnpm dlx vercel env pull