Skip to Content
Edge FunctionsLocal Development

Local Development

You can run the edge functions on your machine against a local Supabase stack, which avoids a redeploy for every change.

Start the local stack

supabase start

This boots Postgres, Auth, Storage and Studio in Docker and prints your local API URL, anon key and service role key.

Apply the migrations

yarn supabase:db-reset

Create the function environment file

The functions read their secrets from supabase/functions/.env when served locally. Copy the template:

cp supabase/functions/.env.example supabase/functions/.env

Then fill in the values. supabase start prints the three SUPABASE_* values you need; OPENROUTER_API_KEY and REVENUECAT_SECRET_KEY are the same ones you’d set as project secrets.

Point SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY at your local stack (http://127.0.0.1:54321 and the service role key from supabase start). Pointing them at production means your local runs read and write your live database.

supabase/functions/.env is git-ignored, so real values never get committed.

Serve the functions

supabase functions serve

They are now reachable at http://127.0.0.1:54321/functions/v1/<name>.

Point the app at your local stack

In .env.local:

EXPO_PUBLIC_SUPABASE_URL="http://127.0.0.1:54321" EXPO_PUBLIC_SUPABASE_ANON_KEY="<anon key from supabase start>"

On a physical device, replace 127.0.0.1 with your machine’s LAN IP.

Verify

A chat message streams back and supabase functions serve prints the request in your terminal. Restore your production values in .env.local when you are done.

Regenerating database types

After changing a migration, regenerate src/lib/db/database.types.ts:

PROJECT_REF=<your-project-ref> yarn supabase:db-types
Last updated on