Skip to content

How to understand a Supabase (with Edge Functions) codebase

A Supabase app usually talks to Postgres straight from the client with `supabase-js`, with row-level security policies deciding what each user can see. Server logic that can't run in the client lives in Edge Functions, which run on Deno.

How to tell it's Supabase (with Edge Functions)

  • A supabase/ folder with config.toml, migrations/ and functions/
  • @supabase/supabase-js and createClient(...) in the app
  • Edge Functions calling Deno.serve in supabase/functions/<name>/index.ts

Where things usually live

supabase/migrations/
SQL migrations: tables, policies, functions, triggers.
supabase/functions/<name>/index.ts
One Edge Function per folder.
supabase/config.toml
Local development settings.
src/lib/supabase.ts
Client creation in the app.

Conventions, not rules. Real projects rename and move things, so confirm against the repository.

Where to start reading

  1. The migrations, for tables and row-level security policies
  2. Every supabase.from(...) call in the app
  3. Edge Functions the app calls with supabase.functions.invoke

How a request moves through the code

  1. 1The app queries a table with supabase.from('table'), sending the user's JWT.
  2. 2Postgres applies row-level security policies for that user.
  3. 3For privileged work, the app invokes an Edge Function.
  4. 4The function runs on Deno, often with the service-role key, and returns a response.

Questions to ask about the repository

  • Which tables does the client query directly, and which policies protect them?
  • Which Edge Functions use the service-role key?
  • Where are database triggers or functions doing hidden work?

What trips people up

  • Security lives in SQL policies, so reading only the TypeScript misses half the access rules.
  • The service-role key bypasses row-level security and must never reach the browser.