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

# PostgreSQL with Supabase

> Supabase is an open source Firebase alternative that provides a managed, highly scalable PostgreSQL database and other infrastructure APIs that can support stateless and serverless applications. Supabase is easy to connect to using either the Supabase API, or standard PostgreSQL connection parameters.

You can view an example of this integration on
[Github](https://github.com/jetify-com/jetify-deploy-integration/tree/main/devbox-json/supabase)

## Setting up Supabase[​](#setting-up-supabase "Direct link to Setting up Supabase")

If you don't have one already, you will first need to create an organization and project in Supabase
to use with Jetify Cloud. If you are just testing Supabase with Jetify, you can create a free
personal organization to start. For more details, see the [Supabase Docs](https://supabase.com/docs)

If you plan to connect using PostgreSQL connection parameters, make sure that you save your Database
password at creation time since you may need it to connect.

## Connecting using the Supabase API or Clients[​](#connecting-using-the-supabase-api-or-clients "Direct link to Connecting using the Supabase API or Clients")

The simplest way to connect to Supabase is via the API or one of Supabase's client libraries.
Connecting via the API also lets you use Supabase's advanced realtime and streaming features.

To connect using the API:

* From your Supabase Project Dashboard, navigate to **Project Settings**, then **API**

* In the API Settings pane, copy the Project URL and Secret Service Role key
  <img src="https://mintcdn.com/jetify/k7lJpyU9i-Y_obPW/docs/cloud/deploys/integrations/supabase/supabase-api-settings.png?fit=max&auto=format&n=k7lJpyU9i-Y_obPW&q=85&s=87bf8930421f46b404cdba99282b86da" alt="Supabase API UI" width="1752" height="1288" data-path="docs/cloud/deploys/integrations/supabase/supabase-api-settings.png" />

* Go to the Jetify Dashboard for your project, and navigate to Secrets. Create the following Secrets
  in the `Prod` environment:
  * `SUPABASE_URL`: the Project URL for your Supabase DB
  * `SUPABASE_KEY`: the secret Service Role Key

<Info>
  If you want to use your Database locally or in a preview environment, you can also set these
  environment variables for the `dev` and `preview` environment
</Info>

<img src="https://mintcdn.com/jetify/k7lJpyU9i-Y_obPW/docs/cloud/deploys/integrations/supabase/supabase-secrets-configuration.png?fit=max&auto=format&n=k7lJpyU9i-Y_obPW&q=85&s=a62c4e59a6f64a7ed397defc22c59110" alt="Secrets set in the Jetify Cloud" width="2100" height="380" data-path="docs/cloud/deploys/integrations/supabase/supabase-secrets-configuration.png" />

When you deploy your application, Devbox will automatically set these secrets as env variables in
your environment. You can use these environment variables when configuring your Supabase client.

For example, if you are connecting from a Python app, you can do something like the following to
connect with the Supabase Python client:

```python theme={null}
from supabase import create_client, Client

url: str = os.getenv('SUPABASE_URL')
key: str = os.getenv('SUPABASE_KEY')
supabase: Client = create_client(url, key)
```

## Connecting via PostgreSQL Connection Parameters[​](#connecting-via-postgresql-connection-parameters "Direct link to Connecting via PostgreSQL Connection Parameters")

You can also connect to your database using the standard PostgreSQL Database connection parameters.
This is useful if your project cannot use the Supabase API, or if it requires a standard PostgreSQL
connection

To connect via PostgreSQL:

* From your Supabase Project Dashboard, navigate to Project Settings, then Database.

* In the Connection Parameters Settings, copy values needed for connection. Your database password
  will be the password you set when creating your project.
  <img src="https://mintcdn.com/jetify/k7lJpyU9i-Y_obPW/docs/cloud/deploys/integrations/supabase/supabase-connection-parameters.png?fit=max&auto=format&n=k7lJpyU9i-Y_obPW&q=85&s=5dff55648e13da34669c4decb7cbbbb0" alt="Supabase Connection Parameters" width="1992" height="894" data-path="docs/cloud/deploys/integrations/supabase/supabase-connection-parameters.png" />

* Go to the Jetify Dashboard for your project, and navigate to Secrets. Create the following Secrets
  in the `Prod` environment:
  * `POSTGRES_HOST`: Your PostgreSQL Host
  * `POSTGRES_PORT`: Your PostgreSQL DB Port
  * `POSTGRES_USER`: Your PostgreSQL Username
  * `POSTGRES_PASSWORD`: Your PostgreSQL Database Password

<img src="https://mintcdn.com/jetify/k7lJpyU9i-Y_obPW/docs/cloud/deploys/integrations/supabase/supabase-postgres-secrets.png?fit=max&auto=format&n=k7lJpyU9i-Y_obPW&q=85&s=bdfa27dbcef2aa227ca280a990024c52" alt="Postgres Secrets" width="2078" height="680" data-path="docs/cloud/deploys/integrations/supabase/supabase-postgres-secrets.png" />

When you deploy your application, Devbox will automatically set these secrets as env variables in
your environment. You can use these environment variables when configuring your PostgreSQL client or
connection.
