Setup
Pre-requisites:
- A Supabase Account
- A Supabase project
1. Supabase Project Connection
- Create a new Supabase project
- Get your Supabase API keys to add the following env vars to your
.envfile:
NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_ANON_KEY=
SUPABASE_SERVICE_ROLE_KEY=
2. Database Migration
Connect to your Supabase database to seed your database.
- Get your Supabase database connection string from the supabase console at this route:
https://app.supabase.com/project/<PROJECT_ID>/settings/database - In your
.envfile, add the following env var:
DATABASE_URL=postgresql://<DB_USER>>:<DB_PASSWORD>@db.<PROJECT_ID>.supabase.co:5432/postgres
- Run migrations
yarn prisma migrate devfrompackages/db - Run
init.sqlto connect triggers and other sql that are unsupported by Prisma
3. Initialize Admin User
Create a Supabase auth user to seed your first auth and db user.
- Go to
https://app.supabase.com/project/<PROJECT_ID>>/auth/usersto invite your first user. This will be the auth user. - Accept the email invite and note the
User UIDkey in the above link. - Connect into your database and create a new row in the
usertable with theauth_idas theUser UID. This will be the database user.
4. Set Admin User Password
Receive reset password emails for your user.
Supabase restricts sending of authentication-related links to white-listed URLs only. Follow the instructions to set this up for your account.
- In
https://app.supabase.com/project/<PROJECT_ID>/auth/url-configuration, add your URLs to the Site URL and Redirect URLs section. - Run the app on localhost, go to the reset password page to trigger the reset password email and follow the steps to create your own password.
- Login to your app.