Supabase

Instructions for configuring PowerSync for a Supabase Postgres database.

Enable logical replication

Supabase has logical replication enabled by default — no action required.

Create a PowerSync Database User

It is not currently possible to create a new user on Supabase with replication permissions without contacting their support. Instead, use the default postgres user.

Create "powersync" Publication

The postgres user does not have access to create a publication for all tables. Instead, list each table explicitly.

This can also be done on the Supabase dashboard in the database Replication page.

CREATE PUBLICATION powersync FOR TABLE public.lists, public.todos;

Connect PowerSync to Your Database

  1. In the PowerSync dashboard project tree, click on "Create new instance":

  1. Give your instance a name, such as "Supabase Testing".

  2. Under the "General" tab, you can change the default cloud region from US to EU or JP if desired (more cloud regions are available, contact us if you need a different region).

  3. Under the "DB Connections" tab, click on the + icon.

  4. Now we get the connection details from Supabase:

    • In your Supabase dashboard, navigate to "Project Settings" -> "Database" -> "Connection string" and select the "URI" tab.

    • Uncheck the "Use connection pooling" checkbox. PowerSync needs to connect to the database directly and cannot use the pooler.

    • Copy the connection string. The hostname should be db.<PROJECT-ID>.supabase.co, and not, for example, aws-0-us-west-1.pooler.supabase.com.

    • Paste this URI in PowerSync instance URI field.

    • Enter the password for the postgres user in your Supabase database: (Supabase also refers to this password as the database password or project password).

    • PowerSync has the Supabase CA certificate pre-configured — verify-full SSL mode can be used directly, without any custom certificates.

  5. Click "Test Connection" and fix any errors.

  6. Under the "Client Auth" tab, enable "Use Supabase Auth".

  7. Click "Save".

PowerSync deploys and configures an isolated cloud environment for you, which will take a few minutes to complete.

Troubleshooting

Supabase is configured with a maximum of 4 logical replication slots, with one often used for Supabase Realtime.

It is therefore easy to run out of replication slots, resulting in an error such as "All replication slots are in use" when deploying. To resolve this, delete inactive replication slots by running this query:

select slot_name, pg_drop_replication_slot(slot_name) from pg_replication_slots where active = false;

Last updated