This document provides instructions for developers to set up and run the Supabase service locally within the KindFi monorepo.
Ensure you have the following installed on your machine:
- Clone the Repository (if you haven't already)
git clone https://github.com/kindfi-org/kindfi.git
cd monorepo/services/supabase- Install Dependencies
bun install- Get Ready For Migrations
To create migrations, please follow this guide, it provides steps to generate migrations, ensure that they work before pushing.
- Start Supabase Services
Use the following command to start the Supabase services:
bun start # supabase startThis will start the Supabase local development environment, including the database, authentication, and storage services.
- Generate Types and Schemas
Generate the necessary types and schemas for the Supabase service:
For Remote Supabase (Production/Staging):
# Option 1: Using the helper script (recommended)
./generate-types.sh <YOUR_PROJECT_ID>
# Option 2: Using npm script with PROJECT_ID env variable
PROJECT_ID=<YOUR_PROJECT_ID> bun run gen:remote
# Option 3: Direct command (prefer bun run types / gen-types.sh — they write atomically)
PROJECT_ID=<YOUR_PROJECT_ID> bun run types:remote
bun run schemasTo find your PROJECT_ID:
- Go to https://supabase.com/dashboard
- Select your project
- Go to Settings > General
- Copy the "Reference ID" (this is your PROJECT_ID)
For Local Supabase:
bun gen # generates what it is in local databaseImportant: After generating types from remote, commit the src/database.types.ts file to your repository so Vercel builds have access to the types.
database.types.ts and database.schemas.ts are force-ignored by Biome (!! in root biome.json) and must never be formatted by biome check --write. Regenerate via bun run gen (local) or bun run gen:remote (remote); scripts write to a temp file first so a failed CLI run cannot truncate the committed file.
- Environment Variables
Copy the sample environment file and update it with your configuration:
cp .env.sample .envUpdate the .env file with the KindFi Supabase project id. This is for remote type generation and to identify the local development host.
Supabase Service Role Key
The SUPABASE_SERVICE_ROLE_KEY is a critical environment variable required for server-side operations with Supabase. It grants admin-level access to your Supabase project and should be handled securely.
Obtaining the Service Role Key
- Go to your Supabase Dashboard: https://supabase.com/dashboard.
- Select the project you're working on.
- In the left sidebar, click on Settings.
- Select Data API from the settings menu.
- Locate the Service Role Key and reveal and copy it:
Signup and OTP emails are sent by Supabase Auth, not the Next.js app. Until custom SMTP is configured on your hosted Supabase project, messages come from Supabase Auth <noreply@mail.app.supabase.io> with the default "Confirm Your Signup" template.
- Open Supabase Dashboard → your project → Authentication → SMTP Settings.
- Enable custom SMTP and enter Resend credentials:
| Field | Value |
|---|---|
| Host | smtp.resend.com |
| Port | 587 |
| Username | resend |
| Password | Your Resend API key (RESEND_SMTP_API_KEY) |
| Sender email | noreply@kindfi.org |
| Sender name | KindFi Notifications |
- Ensure
kindfi.orgis verified in Resend andnoreply@kindfi.orgis allowed as a sender. - Under Authentication → Email Templates, paste the HTML from
services/supabase/templates/:- Confirm signup →
confirmation.html - Magic link →
magic_link.html - Change email address →
email_change.html
- Confirm signup →
- After saving SMTP, review Authentication → Rate Limits (default is 30 emails/hour until adjusted).
services/supabase/config.toml enables Resend SMTP when RESEND_SMTP_API_KEY is set in services/supabase/.env. Restart local Supabase after changing SMTP settings:
bun stop && bun start-
Apply (new) migrations to the local database
bun migrate # When adding new migrations file, this makes sure to apply them. -
Apply migrations by resetting local database completely
bun reset # When adding new migrations file, this makes sure to apply them by resetting from the migrations.
For more detailed instructions and advanced configurations, refer to the Supabase Local Development Guide.