General
Recipes

Supabase

Learn how to set up your app with Supabase as the database provider.

We'll utilize Supabase as the database provider. However, please note that Supabase's authentication feature won't be used, as we rely on Auth.js for authentication. Auth.js will handle user authentication and store user data directly in your database.

Account

If you don't already have one, you can easily create a free account at supabase.io.

Project

If you don't have a project, press click on New Project.

Supabase new project

Connection string

In the Supabase dashboard, click the Connect button in the top row.

Supabase connect button

Select the ORM tab and Drizzle as the tool.

Supabase connect window

We will need the DATABASE_URL. You can ignore drizzle/schema.ts and index.tsx in the connection window since we use node-postgres which does not need any special configuration. Open the apps/dashboard/.env and packages/database/.env files and set the environment variables as follows:

.env
DATABASE_URL="postgresql://postgres.[YOUR-PROJECT-REF]:[YOUR-PASSWORD]@aws-0-[AWS-REGION].pooler.supabase.com:6543/postgres"

Make sure to replace the placeholders with your own values.

Migration

To push the database schema to Supabase, run the following command in the project root:

Terminal
pnpm --filter database push

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