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

# Add a backend with Supabase

> Connect your own Supabase project to give your app a Postgres database, user sign-in, file storage, realtime, and Edge Functions.

Vibely builds the frontend of your app in its cloud sandbox. When your app needs data that survives a refresh, user accounts, file uploads, or server-side code, it uses **Supabase** as the backend: a hosted Postgres database with authentication, storage, realtime, and Edge Functions on top. Describe what you want in the project chat, and Vibely writes the tables, security policies, and functions for you, then wires your app to them.

![Your backend is your own Supabase project](https://cdn.vibely.sh/doc/v1/integrations-supabase.webp)

Vibely does not host a backend of its own. Your app's backend is **your own Supabase project**, in your own Supabase organization, on your own Supabase plan. Vibely connects to it on your behalf so the agent can run migrations and deploy functions, but the data stays in your account and Supabase bills you directly.

## Why Supabase

* **Real data from the first feature.** Tables, sign-in, and file storage work as soon as the project is linked. There is nothing to deploy separately.
* **Secure by default.** Every table the agent creates gets row-level security (RLS) in the same migration, so one user's data is not served to another.
* **You own it.** The database is a normal Supabase project. You can open it in the Supabase dashboard, query it, back it up, or keep using it if you leave Vibely.

## What's included

After you link a Supabase project, the agent can use everything Supabase provides:

| Area | What you can ask for |
| - | - |
| **Postgres database** | Tables, relationships, views, and the SQL migrations that create them |
| **Authentication** | Sign-up and sign-in screens, sessions, and protected pages. See [Authentication](https://docs.vibely.sh/features/backend/auth.md) |
| **File storage** | Storage buckets for uploads such as avatars, documents, and images, with access policies |
| **Realtime** | Live updates when rows change, for chat, dashboards, and collaborative views |
| **Edge Functions** | Server-side code for webhooks, scheduled jobs, and any call that needs a secret key |
| **Secrets** | API keys your Edge Functions read at runtime. See [Secrets](https://docs.vibely.sh/features/backend/secrets.md) |

Your app's AI features run through [Vibely AI](https://docs.vibely.sh/features/backend/ai.md), which also needs a linked Supabase project because its calls are made from an Edge Function.

## Connect Supabase to a project

You can start from either end: ask for a backend feature in the chat, or connect first from the editor.

> [tab] From the chat
>
> Ask for something that needs a backend, for example sign-in or saved data. The agent shows a **Connect Supabase** card in the chat and keeps building on mock data in the same turn, so you can see the feature before any database exists. Select the card whenever you are ready. When the link completes, Vibely starts a new turn that creates the real tables and switches your app from mock data to the database.

> [tab] From the editor
>
> Select the database icon in the editor header (its tooltip reads **Connect to Supabase**), then select **Connect to Supabase**. When your project is already linked, the same menu shows **Supabase Project**, **Open Dashboard**, and **Manage**.

Either way, the connection dialog walks you through the same steps:

**1. Connect your Supabase account**

Select **Connect Supabase account**. Supabase opens in a window where you sign in and authorize Vibely for an organization. Finish in the Supabase window and come back to the editor.

**2. Choose a project**

Pick one of the organization's projects from the list. Vibely links an existing Supabase project. It does not create one from the dialog, so if the organization has no projects yet, select **Open supabase.com**, create one there, and come back.

**3. Link it**

Select **Link** with your project's name. Vibely reads the project's API keys (it never reads your data to link it), checks that the project's services are healthy, and stores the project URL and anon key for your app.

After linking, the dialog shows the **Project ref**, **API URL**, and **Anon key**, with **Change project** and **Open dashboard** actions.

> [!NOTE]
>
> Your Supabase account connection belongs to you, not to one project. Organizations you authorize are available across all your Vibely workspaces, and you choose which Supabase project each Vibely project links to.

> [!TIP]
>
> The Supabase project must be running. A paused Supabase project shows as **Paused** in the project list. Restore it in the Supabase dashboard before linking, or the health check can't complete.

## Build with your database

Once linked, describe the data your app needs in plain language. For example:

```text wrap theme={"system"}
I want a place to keep track of my clients with their name, email, phone number, and notes. I also need deals, with the client, the value, the stage, and the expected close date.
```

The agent:

1. Writes a SQL migration that creates the tables, and enables row-level security with policies in the same migration.
2. Applies the migration to your linked Supabase project.
3. Reads the live schema back before it writes any query, so the code matches what actually exists.
4. Wires your app to the tables with the Supabase client.

After every migration that creates tables, Vibely checks the database for tables with RLS turned off and for policies so permissive they protect nothing, and tells the agent about any it finds.

### Destructive changes need your approval

When a migration or query would delete data, such as `DROP TABLE`, `TRUNCATE`, or a `DELETE` or `UPDATE` with no `WHERE` clause, the turn pauses and asks you to approve it before anything runs. There is no setting that skips this.

### Edge Functions

Ask for server-side behavior, such as "email me when a new lead is added" or "handle the Stripe webhook", and the agent writes an Edge Function in your project's `supabase/functions` folder. Vibely deploys changed functions to your linked Supabase project for you, and pushes your project's [secrets](https://docs.vibely.sh/features/backend/secrets.md) to Supabase's Edge Function secret store before each deploy.

Functions require a signed-in user's token by default. A function is public only when your project declares it, for example a webhook that a third-party service calls.

## Example prompts

| What you want | Example prompt |
| - | - |
| Signed-in app | "Add email sign-in and a projects table where each user only sees their own rows." |
| File uploads | "Let users upload a logo and show it on their profile." |
| Admin view | "Add an admin page listing every signup with their plan, for admins only." |
| Realtime | "Update the order board live when an order's status changes." |
| Scheduled job | "Email me a summary of new signups every morning." |
| Mobile photo capture | "Let me photograph a receipt in the app and store it against the expense." |

## Manage the connection

| Task | Where |
| - | - |
| Open your project in Supabase | Database icon in the editor header → **Open Dashboard** |
| Link a different Supabase project | Database icon → **Manage** → **Change project** |
| See or disconnect authorized organizations | **Customize → Connectors → Supabase** → **Manage Connected Organizations** |
| Make Supabase available to your whole workspace | **Customize → Connectors → Supabase** → **Enable for workspace** |

Changing or removing the link stops the agent from running migrations or reading the schema for that project. It does **not** delete your Supabase project or its data, which stay in your Supabase organization.

> [!WARNING]
>
> **Disconnect Supabase account** disconnects Supabase from your whole Vibely account: every workspace and project loses access to those organizations and their projects until you reconnect.

## Troubleshooting

> [accordion] I see "OAuth permissions missing" or migrations fail with a 403
>
> Supabase rejected the request because your authorization doesn't include the database permissions Vibely needs to run migrations. Select **Reconnect** in the connection dialog to authorize again. Supabase applies permissions when you authorize, and refreshing an existing connection does not pick up new ones, so a fresh authorization is required. If the error persists after reconnecting, contact Vibely support.

> [accordion] "Supabase session expired"
>
> Your Supabase authorization expired or was revoked. Select **Reconnect Supabase** and authorize again. Your project link and data are unaffected.

> [accordion] "Could not verify project health. It may still be starting up."
>
> A newly created or just-restored Supabase project can take a few minutes to start. Wait, then try linking again.

> [accordion] The app still shows mock data
>
> The project isn't linked yet. Ask the agent to connect Supabase again, and it raises the **Connect Supabase** card. Once linked, the agent's next turn moves the app onto the real database.

## FAQ

> [accordion] Who pays for the database?
>
> You do, directly to Supabase, on your Supabase plan. Vibely does not resell database capacity. Building with the agent uses your Vibely credits as usual.

> [accordion] Can two Vibely projects share one database?
>
> Yes. Link the same Supabase project to each. Keep in mind that migrations from either project change the shared schema, so changes in one app can affect the other.

> [accordion] Can I undo a migration?
>
> Migrations are forward-only. The agent writes a new migration that reverses the change rather than editing one that has already been applied. Reverting your code in [version history](https://docs.vibely.sh/features/projects/history.md) does not roll back the database.

> [accordion] Can I use the Supabase dashboard directly?
>
> Yes. It's your project. You can browse tables, run SQL, and manage auth settings in the Supabase dashboard at any time. Tell the agent about changes you make there so it doesn't work from an outdated picture of the schema.

> [accordion] What happens to my data if I leave Vibely?
>
> Nothing. The Supabase project stays in your organization with all its data. See [Ownership](https://docs.vibely.sh/features/deploy/ownership).

## Related

> [card] [Authentication](https://docs.vibely.sh/features/backend/auth.md)
>
> Add sign-in and configure your app's redirect URLs.

> [card] [Secrets](https://docs.vibely.sh/features/backend/secrets.md)
>
> Store API keys your Edge Functions read at runtime.

> [card] [Security best practices](https://docs.vibely.sh/features/security/best-practices.md)
>
> RLS policy patterns and where trust boundaries sit.

> [card] [Vibely AI](https://docs.vibely.sh/features/backend/ai.md)
>
> Add AI features that run from your Edge Functions.


## Related topics

- [From idea to the App Store](https://docs.vibely.sh/guides/from-idea-to-store.md)
- [Add users and authentication](https://docs.vibely.sh/features/backend/auth.md)
- [Add payments to your app](https://docs.vibely.sh/features/grow/payments.md)
- [Store API keys with secrets](https://docs.vibely.sh/features/backend/secrets.md)
- [FAQ](https://docs.vibely.sh/faq.md)


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