Other / Self-hosted

Need help? Simply contact us on Discord and we'll help you get set up.

Enable Logical Replication

PowerSync reads the Postgres WAL using logical replication in order to create sync buckets in accordance with the specified PowerSync Sync Rules.

If you are managing Postgres yourself, set wal_level = logical in your config file:

Alternatively, you can use the below SQL commands to check and enable logical replication:

-- Check the replication type
SHOW wal_level;

-- Enable logical replication
ALTER SYSTEM SET wal_level = logical;

Note that Postgres must be restarted after changing this config.

If you're using a managed Postgres service, there may be a setting for this in the relevant section of the service's admin console.

Create a PowerSync Database User

Create a PowerSync user on Postgres:

-- SQL to create powersync user
CREATE ROLE powersync_role WITH REPLICATION LOGIN PASSWORD 'myhighlyrandompassword';

For read-only access, only the SELECT privilege is required — INSERT, UPDATE and DELETE can be removed.

To restrict read access to specific tables, explicitly list allowed tables for both the SELECT privilege, and for the publication (as well as for any other publications that may exist).

Create "powersync" Publication

-- Create publication to replicate tables. Specify a subset of tables if required.
-- NOTE: this must be named "powersync" at the moment

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 "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. Fill in the connection details on the subsequent screen.

    1. If you want to query your database via the PowerSync dashboard, enable "Allow querying in the editor?".

    2. Also note that if you're using a self-signed SSL certificate for your database server, click the "Download Certificate" button to dynamically fetch the recommended certificate directly from your server.

    3. Note if you get any error such as server certificate not trusted: SELF_SIGNED_CERT_IN_CHAIN, click "Download Certificate" to attempt automatic resolution.

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

  6. Click "Save".

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

Last updated