> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nofire.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Supabase

> Connect a Supabase project to NOFire AI

Connect Supabase to bring a project's health, logs, and data into NOFire's system context. When something breaks, the project's services and logs are the evidence NOFire reasons over.

You authenticate with a Supabase personal access token and the ref of one project. A connection reads that one project.

## What NOFire reads

| Signal | What NOFire reads |
| - | - |
| **Project and service health** | The project's name, region, and status, and the health of each of its services |
| **Logs** | The project's `api`, `postgres`, `auth`, and `functions` log streams over a time window |
| **Data** | One read-only `SELECT` at a time, run through Supabase's read-only SQL endpoint. NOFire refuses any other statement before it sends it |

A paused project has no services to read. NOFire reports its status only.

## Prerequisites

* A Supabase account with access to the project.
* The project's **Project ref**.
* Permission to create a personal access token.

## Step 1: Create a Supabase access token

> [accordion] Create a personal access token in Supabase
>
> 1. Open [Account, Access Tokens](https://supabase.com/dashboard/account/tokens) in Supabase.
>
> 2. Create a personal access token.
>
> 3. Copy the token now. You cannot view it again after you leave the page.
>
> > [!NOTE]
> >
> > Use a dedicated token named `nofire` so you can rotate or revoke it without touching other integrations. A personal access token carries your account's access. The connection only reads the one project you name.

> [accordion] Find the Project ref
>
> The 20-letter ref in your project's URL.

## Step 2: Add Supabase connection to NOFire AI

1. Open [Connections](https://my.nofire.ai/dashboard/connections) and click **Connect** on **Supabase**.
2. Fill in the form:
   * **Name**: defaults to `supabase` (for example, `production-supabase`)
   * **Access token**: masked. Create a personal access token in Supabase under Account, Access Tokens.
   * **Project ref**: for example, `abcdefghijklmnopqrst`
3. Click **Connect**.

NOFire checks the token before it saves the connection. It reads the project and its service health. An unhealthy service does not fail the check, because explaining it is NOFire's job. A saved connection shows the toast **Connection created** followed by its name.

## Connect the database through PostgreSQL

The Supabase connection reads health, logs, and read-only query results. For query performance, lock activity, and `pg_stat_*` views, also connect the project's Postgres database with the PostgreSQL connector. The two connections are independent. You can use either or both.

1. In Supabase, create a read-only role for NOFire. Follow [Step 1 of the PostgreSQL page](https://docs.nofire.ai/databases/postgresql.md#step-1-create-a-read-only-role-in-postgresql).
2. Copy the database connection string or host details from your project's database settings in Supabase.
3. Follow [Step 2 of the PostgreSQL page](https://docs.nofire.ai/databases/postgresql.md#step-2-add-postgresql-connection-to-nofire-ai) to add the connection from [Connections](https://my.nofire.ai/dashboard/connections), using the role from step 1.

> [!TIP]
>
> Name the connection after the project, for example `production-supabase-db`, so it is easy to tell apart from the Supabase connection.

## Test the connection

1. Open [Connections](https://my.nofire.ai/dashboard/connections) and make sure that the Supabase connection shows **Connected**. A connection that shows **Failing** did not authenticate.
2. Ask NOFire a question that needs project context, for example "is my Supabase project healthy?". An answer that names your project confirms the connection works end to end.

## Troubleshooting

The form shows the toast **Supabase connection test failed** with one of these reasons.

> [accordion] Supabase rejected supabase\_access\_token: check that it is valid and has not expired
>
> The token is wrong, revoked, or expired. Create a new one under Account, Access Tokens.

> [accordion] Supabase refused supabase\_project\_ref: check it is the 20-letter project ref and that the token's account can read that project
>
> The ref is not the 20-letter ref from the project's URL, or the token's account has no access to that project.

> [accordion] The token cannot read this project's health: check that the token's account has access to the project
>
> The account behind the token cannot read the project's services.

> [accordion] The Supabase project is paused: restore it in the Supabase dashboard, then test again
>
> A paused project fails the check. Restore it in Supabase, then connect again.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.