Railway + PowerSync

Integration guide for deploying a Postgres database and custom backend using Railway for Postgres and Node.js hosting.

Railway is an attractive alternative to managed solutions such as Supabase, well suited to users looking for more control without going the full IaaS route.

Deploying to Railway

Step 1: Deploy on Railway

Find the PowerSync template on the Railway Marketplace, or click below:

Step 2: Configure Your Database

  • Create a powersync publication as described in the Source Database Setup section.

    • Optionally filter the publication table list to only include tables that you want clients to download

  • [Optional] Create a Postgres user for PowerSync to use as described in the Source Database Setup section.

Step 3: Configure Railway and PowerSync

  • Once your project is deployed, clone the repo that Railway created and follow the instructions to generate the JWT config for these environment variables:



  • Sign up for a PowerSync account

  • Follow the steps to create a PowerSync instance as documented here: Database Connection

    • Generate a server certificate (in PEM format) via the following command:

    echo | openssl s_client -showcerts -starttls postgres -connect <host>:<port> -servername <host> 2>/dev/null | sed -n '/BEGIN CERTIFICATE/,/END CERTIFICATE/p' | awk '/BEGIN/{i++}i==2' > railway.pem

    • Replacing <host> and <port> values with your own.

    • In your Dashboard's connection details form, select "verify-ca" as the SSL mode, and upload the "railway.pem" file into the "Server Certificate" field.

  • Once your instance has been provisioned, right-click on the instance and copy the instance URL

  • Set this as the POWERSYNC_URL environment variable in Railway

Step 4: Build Out Your Database

This typically consists of the below activities:

  • Create your schema

  • Add any new tables to the powersync publication previously created

  • Load some test data

Step 5: Build Out Your Backend

See the Node.js backend app for instructions:


An example implementation using Firebase for auth is available here:


Step 6: Connect Your Client

See these docs for instructions to connect your app to your backend and PowerSync: Client-Side Setup

Last updated