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
2. Get connection strings
In the supabase dashboard, navigate to Settings > Database. Here you will find two connection strings, that we will need later.
Migration connection string
For the database migrations, we will use the regular connection string that you can find under Connection String in the URI tab.
Application connection string
The second connection string will be used for the application to connect to the database. You can find it under Connection Pooling Custom Configuration.
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-eu-central-1.pooler.supabase.com:6543/postgres?pgbouncer=true"
Then add the following env below that line:
# The migration connection string
MIGRATION_DATABASE_URL="postgres://postgres:[YOUR-PASSWORD]@db.[YOUR-PROJECT-REF].supabase.co: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")
}
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.