How to set up supastarter with Supabase

Jonathan Wilke

Jonathan Wilke

9/29/2023

#Supabase#Guide
How to set up supastarter with Supabase

In this guide we show you how you can easily set up your supastarter SaaS using Supabase.

Before we start, make sure you have a Supabase account. If you don't have one yet, you can create one for free at supabase.io.

1. Create a new Supabase project

Create a new Supabase project

2. Get connection strings

In the supabase dashboard, navigate to Settings > Database. Here you will find the connection string, that we will need later.

We will need both the transaction mode string and the session mode string:

Supabase connection string

3. Create a new supastarter project

As described in the supastarter documentation, you can create a new supastarter project by running the following command:

npx supastarter new

In the CLI wizard, you will be asked for the database connection string. Paste the connection string you copied in step 2. Make sure to replace the password placeholder in the connection string with the one you created in step 1.

4. Fix envs for migration connection

There is one special case for the migration connection. In the supastarter project, open the .env.local file and change the DATABASE_URL to the following:

# The application connection string
DATABASE_URL=postgres://postgres.[YOUR-PROJECT-REF]:[YOUR-PASSWORD]@aws-0-[aws-region].pooler.supabase.com:6543/postgres?pgbouncer=true&connection_limit=1

Then add the following env below that line:

# The migration connection string
MIGRATION_DATABASE_URL=postgres://postgres.[YOUR-PROJECT-REF]:[YOUR-PASSWORD]@aws-0-[aws-region].pooler.supabase.com:5432/postgres

Make sure to replace the password and project ref placeholders with your own values.

Next we need to add the migration connection to the prisma/schema.prisma file. Add the following line to the top of the file:

datasource db {
  provider  = "postgresql"
  url       = env("DATABASE_URL")
  directUrl = env("MIGRATION_DATABASE_URL")
}

After the migrations are run, make sure to enable RLS for all created tables in the Supabase dashboard.

5. Run development server

Now you should be able to start the development server by running the following command in the project root:

pnpm dev

That's all it takes to set up supastarter with Supabase! If you have questions, feedback or feature requests, feel free to reach out to us on Twitter or on the supastarter Discord server.

Ship your SaaS in months days

Save time and focus on your business with supastarter, the scalable and production-ready starter kit for your SaaS.

Get started

Stay up to date

Sign up for our newsletter and we will keep you updated on everything going on with supastarter.