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

# Supabase Integration

> Connect Supabase for database and authentication via OAuth

# Supabase Integration

Supabase is an open-source Firebase alternative providing PostgreSQL database, authentication, storage, and edge functions. This guide covers how Supabase works with Newly.

## How Supabase Works in Newly

In general, when creating a project in Newly, Liquid Backend is automatically enabled if your prompt covers anything that might need backend functionality.

<Note>
  **Not sure which backend you're using?** If the tab labeled "Database" instead shows "Supabase", your project is connected to Supabase. See [Backend Systems](/features/backend) for details.
</Note>

If you have good reasons for using supabase instead, such as; already having a website with Supabase and you want to use the same database for your app - then you can go to "More" and connect your Supabase account.

After connecting, the AI automatically has access to update your database schema, add or modify edge functions, alter RLS policies and view edge function logs.

## Connecting Supabase

Newly uses OAuth to securely connect to your Supabase project—no manual API keys required.

<Steps>
  <Step title="Open Supabase Settings">
    Click **More** → **Supabase** in the project menu
  </Step>

  <Step title="Connect via OAuth">
    Click "Connect Supabase" and sign in to your Supabase account
  </Step>

  <Step title="Authorize Access">
    Grant Newly permission to access your Supabase projects
  </Step>

  <Step title="Select Project">
    Choose the Supabase project you want to connect
  </Step>

  <Step title="Connected">
    Your Supabase project is now linked to your Newly app
  </Step>
</Steps>

<Tip>
  The OAuth connection handles all authentication automatically. You don't need to manually copy API keys or configure environment variables for the Supabase connection.
</Tip>

## Using Supabase in Your App

Once connected, tell the AI what you want to build:

```
Create a posts feature using my Supabase database.
Show a list of posts and let users create new ones.
```

The AI will generate the appropriate code to interact with your Supabase database.

### What You Can Ask For

* **Database operations** - Create, read, update, delete records
* **Authentication** - Sign up, login, password reset using Supabase Auth
* **Storage** - Upload and display images and files
* **Realtime** - Subscribe to live database changes

## Managing Your Database

When your project is connected to Supabase, the **Database** tab shows your Supabase project details, secrets, and a link to open the Supabase Dashboard instead of Newly's built-in table browser. Full data management — browsing rows, running SQL, editing schema — still happens in the Supabase Dashboard.

### Supabase Dashboard

Manage your database at [supabase.com/dashboard](https://supabase.com/dashboard):

| Feature             | Where to Find     |
| ------------------- | ----------------- |
| **View/Edit Data**  | Table Editor      |
| **Run SQL Queries** | SQL Editor        |
| **Create Tables**   | Database → Tables |
| **Manage Auth**     | Authentication    |
| **File Storage**    | Storage           |
| **Edge Functions**  | Edge Functions    |

### Creating Tables

In Supabase Dashboard:

1. Go to **Table Editor**
2. Click **New Table**
3. Define columns with types and constraints
4. Enable Row Level Security (RLS)

<Warning>
  Always enable Row Level Security (RLS) on your tables for security. Without RLS, anyone with your project URL could access your data.
</Warning>

## Authentication with Supabase

Supabase Auth provides multiple authentication methods:

```
Add login and signup using Supabase authentication.
Support email/password.
```

<Warning>
  **Social login like Google OAuth require a Google OAuth key to be set up in Google Cloud for Supabase projects - Liquid Backend provides Google OAuth without any setup for development purposes.**
</Warning>

<Card title="Apple & Google Login with Supabase" icon="fingerprint" href="/guides/supabase-social-login">
  Step-by-step walkthrough for adding Sign in with Apple and Sign in with Google to a Supabase-backed app.
</Card>

### Supported Auth Methods

| Method         | Setup Required                  |
| -------------- | ------------------------------- |
| Email/Password | Ready to use                    |
| Magic Links    | Ready to use                    |
| Google OAuth   | Configure in Supabase Dashboard |
| Apple OAuth    | Configure in Supabase Dashboard |
| GitHub OAuth   | Configure in Supabase Dashboard |
| Phone/SMS      | Requires Twilio setup           |

## Viewing Supabase Logs

Access logs in the Supabase Dashboard:

1. Go to [supabase.com/dashboard](https://supabase.com/dashboard)
2. Select your project
3. Click **Logs** in the sidebar

| Log Type               | What It Shows                        |
| ---------------------- | ------------------------------------ |
| **API Logs**           | REST API requests, response codes    |
| **Postgres Logs**      | Database queries, errors             |
| **Auth Logs**          | Login attempts, signups, OAuth flows |
| **Edge Function Logs** | Serverless function execution        |
| **Realtime Logs**      | WebSocket subscription events        |

### Frontend Logs in Newly

While Supabase logs aren't directly available in Newly, you can still view frontend console logs:

1. Click the **Logs** icon in the preview header
2. View console.log output, errors, and warnings from your React Native code

## Row Level Security (RLS)

RLS is crucial for Supabase security. Configure policies in the Supabase Dashboard under **Authentication → Policies**.

Common patterns:

* **Users read own data** - Only see records where user\_id matches
* **Public read, authenticated write** - Anyone can view, only logged-in users can create
* **Admin access** - Full access for admin users

<Warning>
  Without RLS enabled, your data is publicly accessible. Always configure appropriate policies before going to production.
</Warning>

## Storage

For file uploads, tell the AI:

```
Let users upload profile pictures and display them on their profile.
Store the images in Supabase Storage.
```

Configure storage buckets and policies in the Supabase Dashboard under **Storage**.

## Edge Functions

For server-side logic requiring secrets (like OpenAI API calls), use Supabase Edge Functions:

1. Create functions in Supabase Dashboard → Edge Functions
2. Deploy via Supabase CLI
3. Tell the AI to call your edge function from the app

<Note>
  Edge Functions are useful when you need server-side processing that can't be done safely in the frontend.
</Note>

## Migrating from Liquid Backend to Supabase

<Warning>
  **Migration from Supabase to Liquid Backend is not possible.** However, you can migrate from Liquid Backend to Supabase if you have specific requirements that only Supabase can meet.
</Warning>

### When to Consider Migration

In most cases, **Liquid Backend will get you further**. Consider Supabase only if you already have a website with Supabase or an existing Supabase database that you need to use.

## Troubleshooting

<AccordionGroup>
  <Accordion title="Connection failed">
    * Try disconnecting and reconnecting via **More** → **Supabase**
    * Check your Supabase project isn't paused (free tier pauses after inactivity)
    * Verify you authorized the correct Supabase account
  </Accordion>

  <Accordion title="Permission denied / 403errors when using the app">
    * Ask Newly AI about Row Level Security policies
    * Manually check Row Level Security policies in Supabase Dashboard
    * Verify the user is authenticated if your policies require it
    * Review policies under Authentication → Policies
  </Accordion>

  <Accordion title="Can't see backend logs">
    Backend logs for Supabase are only available in the Supabase Dashboard, not in Newly. Go to supabase.com/dashboard → Logs.
  </Accordion>

  <Accordion title="Data not showing in app">
    * Check the Table Editor in Supabase Dashboard to verify data exists
    * Check RLS policies aren't blocking access
    * Look at API Logs in Supabase for errors
  </Accordion>
</AccordionGroup>

## Resources

<CardGroup cols={2}>
  <Card title="Supabase Docs" icon="book" href="https://supabase.com/docs">
    Official Supabase documentation
  </Card>

  <Card title="Supabase Dashboard" icon="gauge" href="https://supabase.com/dashboard">
    Manage your database
  </Card>

  <Card title="Backend Systems" icon="server" href="/features/backend">
    Compare Supabase vs Liquid Backend
  </Card>

  <Card title="Liquid Backend" icon="bolt" href="/features/backend">
    Liquid Backend documentation
  </Card>
</CardGroup>
