# Set up Relia in a Supabase app

> Watch a Supabase app in three parts: the web app's table reads and writes, your Edge Functions, and the database's own statistics.

Section: Set up your stack · Page: https://tryrelia.com/docs/supabase-setup · Last checked against the product: 2026-11-01
Video walkthrough: https://youtu.be/lgFYplJANic

Many Supabase apps talk to the database straight from the browser, with no server of their own. Relia sees those calls too. This page sets up three parts; do the ones your app has. To have your AI assistant do it instead, see [Set up Relia with your AI assistant](https://tryrelia.com/docs/setup-with-ai-assistant.md).

## Before you start

- A Relia account ([Create your account](https://tryrelia.com/docs/create-account.md)).
- Your project's id and key, for the Edge Functions part. In Relia, open your project, click **Setup Guide & SDK** and pick **Supabase**: the steps there have your values filled in.

## Steps

### Part 1: the web app

1. In your web app's folder, run:

   ```bash
   npx relia-sdk@latest init
   ```

2. Sign in, choose **Everything Relia found here**, pick your project and answer the two questions. The full walkthrough is in [Watch your web app](https://tryrelia.com/docs/web-app-setup.md).

That's all `supabase-js` needs. Relia recognizes its calls by itself:

- **Every table read and write** appears on the **Database** page: the table, the operation, and the filters **without their values**. `?email=eq.ann@shop.io` is stored as `WHERE email = ?`, and the query string never leaves the browser.
- **A write refused by a row level security policy** is named as such, not just shown as a 403.
- **Sign-ins and sign-ups** are counted by outcome.
- Storage uploads and Edge Function calls show as calls to Supabase.

Your Supabase anon key is never stored.

### Part 2: Edge Functions

1. **Wrap each function's handler** in `supabase/functions/<name>/index.ts`. The handler itself stays unchanged:

   ```ts
   import { withRelia } from "npm:relia-sdk/edge"

   Deno.serve(withRelia(async (req) => {
     // your handler, unchanged
   }))
   ```

2. **Give the functions their settings** once (the same for every function):

   ```bash
   supabase secrets set RELIA_PROJECT_ID=<your project id> RELIA_KEY=<your project key> RELIA_SERVICE_NAME=shop-functions
   ```

3. **Testing locally** with `supabase functions serve`? The local server stops a function right after it answers, which cuts off sending. Add the settings to `supabase/functions/.env`, plus two more lines:

   ```bash
   RELIA_PROJECT_ID=<your project id>
   RELIA_KEY=<your project key>
   RELIA_SERVICE_NAME=shop-functions
   RELIA_ENV=development
   RELIA_FLUSH=before
   ```

   Make sure `.gitignore` covers `supabase/functions/.env`.

Each call becomes a request named after the function, its `supabase-js` table calls become database calls, and its `fetch` calls become outgoing calls. In production the data is sent after the response, so your users never wait for it.

> **Tip:** the same wrapper works on Cloudflare Workers, Vercel Edge and Deno. See [Set up edge runtimes](https://tryrelia.com/docs/edge-runtimes-setup.md).

### Part 3: inside your database (optional)

Relia can also read your database's own statistics:

- slow queries as Postgres measures them, including ones no app call shows, like those from scheduled jobs;
- scheduled jobs (pg_cron) that fail, and jobs that stop running;
- connections running out, and the database's size.

1. In Relia, open **Database** and click **Connect**.
2. Copy the SQL snippet Relia shows and run it once in Supabase's **SQL editor**. It creates a login called `relia_monitor` that can read statistics only and can't see or change your data. The password is made for you and shown only there. No pg_cron? Skip the snippet's last two lines.
3. In Supabase, open **Connect** and copy the **Session pooler** connection string, with the user `relia_monitor` and the password from the snippet.
4. Paste it into Relia and click **Connect**.

Relia refuses any login that can read your tables, stores the connection string encrypted, and reads every 5 minutes. If your database has network restrictions on, allow Relia's server first.

> **Tip:** watch [Database monitoring for Postgres, MongoDB and Supabase](https://youtu.be/zpZNjfd7mVk) (2 min).

## Linking the web app to a function (optional)

To see a browser call and the function it reached as one story, do both:

- add `propagateTo: ["*.supabase.co"]` to `Relia.init`;
- add `traceparent` to the function's `Access-Control-Allow-Headers`.

Do both or neither: without the CORS change, the browser refuses the call.

## Check it worked

Open your web app once, and call a function if you set those up. On your project's **Setup** tab, **Visits to your web app** changes from *Not yet* to *Arriving*, and **Requests from your server** too once a function has been called. Your table reads and writes appear under **Database**.

## If something's wrong

- **Function calls never arrive when testing locally:** add `RELIA_FLUSH=before` to `supabase/functions/.env`.
- **Connect refuses the login:** use the `relia_monitor` login from the snippet, not your admin password. Relia refuses any login that can read or change your tables.
- **No table calls on Database:** make sure the web app part is set up and you've used the app once. See [Relia shows no data](https://tryrelia.com/docs/no-data.md).

## Next

- [Identify your users](https://tryrelia.com/docs/identify-users.md)
- [Database monitoring](https://tryrelia.com/docs/database.md)
- [Find slow database queries](https://tryrelia.com/docs/slow-database-queries.md)

---
All Relia docs for AI assistants: https://tryrelia.com/llms.txt (index) · https://tryrelia.com/llms-full.txt (everything in one file)
