Skip to main content
Railway is an attractive alternative to managed solutions like Supabase, giving you more control without the complexity of full IaaS management.

Step 1: Deploy on Railway

Find the PowerSync template on the Railway Marketplace, or click the button below to get started:

Deploy on Railway

This template automatically creates lists and todos tables in your Postgres database. The default Sync Rules are configured to sync these tables to your clients.The Execute Scripts service creates the powersync publication for these tables. We recommend limiting the publication to only the tables you want clients to download.
Once you’re up and running with the default lists and todos tables, you can add more tables at any time using either of these approaches:Option 1: Use your existing Postgres toolsManage your database schema as you normally would. For example, using psql:
psql $POSTGRES_URL <<'SQL'

CREATE TABLE notes (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  list_id UUID REFERENCES lists(id) ON DELETE CASCADE,
  content TEXT,
  created_at TIMESTAMP DEFAULT now()
);

CREATE PUBLICATION powersync FOR TABLE notes;

SQL
Option 2: Use the Execute Scripts serviceThe Execute Scripts service can also be used as a general-purpose tool to apply schema changes to your PowerSync Postgres instance:
  1. Add your new table creation statements and publication updates to the Execute Scripts code
  2. Redeploy the Execute Scripts service
After adding tables with either option:
  1. Update the Sync Rules in your YAML config (Step 2) to include the new tables
  2. Re-encode the YAML to base64 and update the POWERSYNC_CONFIG_B64 environment variable

Step 2: Configure PowerSync Service

You’ll notice the PowerSync service deployment crashes initially. This is expected, the POWERSYNC_CONFIG_B64 environment variable isn’t set yet.
Let’s fix this by generating the config, setting the variable, and restarting the service.
1

Copy the YAML config

Start with the configuration below and update the Sync Rules to match your schema:
replication:
  connections:
    - type: postgresql
      uri: ${POSTGRES_SOURCE_URL}
      sslmode: disable

storage:
  type: postgresql
  uri: ${POSTGRES_BUCKET_URL}
  sslmode: disable

port: 80

sync_rules:
  content: |
    bucket_definitions:
      global:
        data:
          - SELECT * FROM lists
          - SELECT * FROM todos

client_auth:
  jwks_uri: https://${BACKEND_PUBLIC_URL}/api/auth/keys
  audience:
    - https://${POWERSYNC_PUBLIC_URL}
2

Replace the placeholders

Replace each placeholder with the corresponding values from Railway:
Click on Postgres Source DataVariables → copy DATABASE_URL
Click on Postgres (PowerSync Bucket Storage)Variables → copy DATABASE_URL
Click on Node BackendSettingsNetworking → copy the URL
Click on PowerSync ServiceSettingsNetworking → copy the URL
3

Encode and deploy

Once you’ve replaced all placeholders:
  1. Use a base64 encoding tool to encode the YAML file
  2. Copy the encoded string to the POWERSYNC_CONFIG_B64 environment variable in the PowerSync Service
  3. Redeploy when prompted

Step 3: Test with the diagnostics app

  1. Generate a development token
  2. Open the PowerSync Diagnostics App service
  3. Paste your token to test your connection and Sync Rules

Step 4: Connect Your Client

Client-Side Setup

Follow our guide to connect your app to your backend and PowerSync instance