# Database

### Overview

Supabase is a **direct API integration**, which means your app connects to Supabase by using Supabase client libraries and your own project credentials.

This page explains what's needed from the user, how to set up the frontend and backend, how authentication works, and the security rules you must follow.

### Supabase Capabilities

Connecting Supabase gives your app a production-grade backend, including:

* **Database (PostgreSQL)**\
  Store and query your data with full SQL support. Tell Cody what your interface needs to show and what your database needs to include, and Cody can create the tables and schema that match your data.
* **User authentication**\
  Add secure sign-ups, logins, and access control. Cody can generate authentication flows (like email/password) and connect them to the right pages and permissions in your app.
* **File storage**\
  Upload and serve images and files using Supabase Storage — useful for profile photos, attachments, and user uploads.
* **Real-time updates**\
  Stream changes as data updates. This is useful for chat, live activity feeds, and dashboards that update instantly across users.
* **Edge Functions**\
  Run serverless backend logic on Supabase using JavaScript/TypeScript. Cody can create and deploy functions for tasks like sending emails, handling webhooks, processing payments, or integrating with external APIs.

### Connecting Supabase

{% stepper %}
{% step %}
Register a new Supabase account [**here**](https://app.supabase.com/sign-up) or [**sign in**](https://app.supabase.com/sign-in) if you already have one.

Create an organization if you don't have one.

<figure><img src="/files/YEStptxS6td7J0j7jGHg" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Create a **new project** in Supabase.

Click on + New Project, complete the necessary fields, and allow a few minutes for setup.

<figure><img src="/files/SFh8wJrKmSHo29IXwWu7" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Share the the **Supabase Project URL** to Cody

<figure><img src="/files/wwSVaCtJuF5DnG8yVTVA" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Provide the Cody with the anon public key and the service role secret

Navigate to **Project Settings - API Keys**

<figure><img src="/files/VfXGcJbpul8kV8AHz6KV" alt=""><figcaption></figcaption></figure>

Copy both the **anon public key** & the **service role secret** and share it with Cody

<figure><img src="/files/pKiIzfuCXCy4cKUyzA3L" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

Cody will safely store all your secrets and help you with integrating a database for your needs.

When Cody asks you to run SQL queries on supabase, click on the **SQL editor** from your supabase dashboard located at the top right corner or **command +E** shortcut on Mac devices.

<figure><img src="/files/agn9cGwYysTQxeUiM7Qa" alt=""><figcaption></figcaption></figure>

This will open the **SQL Editor** where you can **copy and paste** the SQL query and click **Run** at the bottom right to execute the SQL query.

<figure><img src="/files/IjKeqnerxsHEx3IKyINX" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.codewords.ai/website-builder/features/database.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
