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

# Supabase Integration

> Connect HelloLeo to your Supabase backend

Connect HelloLeo to your Supabase project to interact with your database, authentication, storage, and other Supabase services.

## Setup

1. Go to **Project Settings** → **Project Integrations**
2. Select **Supabase** from the list
3. Enter your credentials:
   * **Access Token** - Your Supabase access token
     * Get it from [Supabase Account Tokens](https://supabase.com/dashboard/account/tokens)
4. Test the connection
5. Start using Supabase in your prompts

## How It Works

HelloLeo uses the Supabase MCP (Model Context Protocol) to interact with your Supabase project. Your access token is encrypted and stored securely on the backend.

## Environment Variables

When you configure Supabase, the following environment variables are automatically set up:

* `VITE_SUPABASE_URL` - Your Supabase project URL
* `VITE_SUPABASE_ANON_KEY` - Your Supabase anonymous/public key

These environment variables allow your frontend code to connect directly to your Supabase instance.

## Common Operations

With Supabase integration, you can:

* **Query databases** - Access your Supabase PostgreSQL database
* **Manage authentication** - Work with Supabase Auth users
* **Handle storage** - Manage files in Supabase Storage
* **Use real-time** - Subscribe to real-time database changes
* **Call functions** - Execute Supabase Edge Functions

## Example Usage

### Display Data

```
Show all users from my Supabase database. Display email, 
created_at, and last_sign_in_at.
```

### Query Database

```
Find all products in Supabase where price is greater than 100. 
Display name, price, and category.
```

### Create Records

```
Create a new record in my Supabase "orders" table with customer_id 
123, total 99.99, and status "pending".
```

### Update Records

```
Update the order with ID 456 in Supabase to set status to "completed".
```

### Manage Storage

```
Upload the selected file to Supabase Storage in the "documents" bucket.
```

## Best Practices

* **Use environment variables** - Reference `VITE_SUPABASE_URL` and `VITE_SUPABASE_ANON_KEY` in your code
* **Specify tables** - Always mention which Supabase table you're working with
* **Mention the integration** - Always say "from Supabase" or "to Supabase" so Leo knows which integration to use
* **RLS policies** - Be aware of Row Level Security policies that may affect data access

## Troubleshooting

### Connection Issues

* **Check access token** - Verify your Supabase access token is correct
* **Token permissions** - Ensure your token has the necessary permissions
* **Project URL** - Verify your Supabase project URL is correct

### Data Not Showing

* **Check table name** - Ensure you're using the correct table name
* **RLS policies** - Verify Row Level Security policies allow access
* **Permissions** - Check that your access token has read permissions

### Can't Create/Update

* **Write permissions** - Ensure your access token has write permissions
* **RLS policies** - Check that RLS policies allow insert/update operations
* **Required fields** - Make sure all required fields are provided
* **Data format** - Verify data matches your table schema

<CardGroup cols={2}>
  <Card title="Working with Integrations" icon="plug" href="/integrations/working-with-integrations">
    Learn how to use integrations effectively
  </Card>

  <Card title="Network Monitor" icon="activity" href="/features/network-monitor">
    Debug Supabase API calls
  </Card>
</CardGroup>
