Deploying to Railway
Step 1: Deploy on Railway
Find the PowerSync template on the Railway Marketplace, or click below:Deploy on Railway
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:
POWERSYNC_JWT_PRIVATEKEY
POWERSYNC_JWT_PUBLICKEY
- 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.
- Generate a server certificate (in PEM format) via the following command:
- Once your instance has been provisioned, copy its instance URL (find the copy icon in the Project tree).
- 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