Configuration Methods
The PowerSync Service is configured using key/value pairs in a config file, and supports the following configuration methods:- Inject config as an environment variable (which contains the Base64 encoding of a config file)
- Use a config file mounted on a volume
- Specify the config as a command line parameter (again Base64 encoded)
self-host-demo app.
Environment Variable Substitution
The config file uses custom tags for environment variable substitution. Using!env [variable name] will substitute the value of the environment variable named [variable name]. For example, with the environment variable PS_MONGO_URI=mongodb://mongo:27017/powersync, the YAML
uri: mongodb://mongo:27017/powersync.
Only environment variables with names starting with PS_ can be substituted.
Configuration File Structure
Below is a skeleton config file with the most common options. See the Configuration Reference for all available options.service.yaml
Supplementary Resources
These external resources supplement the Configuration Reference below:Example service.yaml with detailed comments
A working config example from the
self-host-demo app, including environment variable substitution.Config file JSON schema
A machine-readable schema of the config file, published as
@powersync/service-schema.Configuration Reference
The config file supports the following top-level keys, documented in the sections below:replication
Specify the connection to your source database inreplication.connections. Only one connection is currently supported; multiple connection support is on the roadmap.
For instructions on preparing your source database, see Source Database Setup.
If you are using hosted Supabase, you will need to enable IPv6 for Docker as per the Docker docsIf your host OS does not support Docker IPv6 e.g. macOS, you will need to run Supabase locally.This is because Supabase only allows direct database connections over IPv6 — PowerSync cannot connect using the connection pooler.
string
required
The connection type. One of
postgresql, mongodb, mysql, mssql, or convex.string
default:"default"
Unique identifier for the connection. Optional when only a single connection is present.
string
default:"default"
Additional meta tag for the connection, used for categorization or grouping.
boolean
default:"false"
When enabled, allows executing queries against this connection through the service’s admin API (authenticated using
api.tokens).string[]
Block connections to any of these IP ranges. Include
local to block anything not in public unicast ranges.Postgres connection options
Postgres connection options
service.yaml
string
Connection URI in the format
postgresql://user:password@hostname:5432/database. Individual connection parameters take precedence over values in the URI.string
Database hostname. Required if not specified in
uri.number
default:"5432"
Database port.
string
Database username. Required if not specified in
uri.string
Database password. Required if not specified in
uri.string
Database name. Required if not specified in
uri.string
default:"verify-full"
SSL mode:
verify-full, verify-ca, or disable. disable is only suitable for local/private networks, not for public networks.string
CA certificate content in PEM format. Required for
verify-ca, optional for verify-full.string
Client certificate content in PEM format, for TLS client authentication.
string
Client private key content in PEM format, for TLS client authentication.
string
Use a servername for TLS that is different from
hostname.string
default:"powersync_"
Prefix for Postgres logical replication slot names and replication stream names.
number
default:"8"
Maximum number of connections to the source database, per service process.
number
Connection timeout in seconds. Takes precedence over a
connect_timeout query parameter in the URI.number
default:"60"
Interval in seconds between source connection heartbeats. Must be between 5 and 60.
MongoDB connection options
MongoDB connection options
service.yaml
string
required
Connection URI in the format
mongodb:// or mongodb+srv://. Standard connection options such as connectTimeoutMS, socketTimeoutMS, serverSelectionTimeoutMS, maxPoolSize and maxIdleTimeMS can be set as query parameters in the URI.string
Database name. Defaults to the database in the URI path.
string
Database username. Defaults to the username in the URI.
string
Database password. Defaults to the password in the URI.
string
default:"off"
Controls how change stream post-images are used:
off, auto_configure, or read_only. auto_configure is recommended for new instances. See Post Images for details on each option.number
default:"60"
Interval in seconds between source connection heartbeats. Must be between 5 and 60.
MySQL connection options
MySQL connection options
MySQL support is currently in a Beta release.
service.yaml
string
Connection URI in the format
mysql://user:password@hostname:3306/database. Individual connection parameters take precedence over values in the URI.string
Database hostname. Required if not specified in
uri.number
default:"3306"
Database port.
string
Database username. Required if not specified in
uri.string
Database password. Required if not specified in
uri.string
Database name. Required if not specified in
uri.number
default:"1"
Server ID used when connecting as a replication client.
string
CA certificate content in PEM format.
string
Client certificate content in PEM format, for TLS client authentication.
string
Client private key content in PEM format, for TLS client authentication.
number
default:"50"
The combined size in MB of binlog events that can be queued in memory before throttling is applied.
SQL Server connection options
SQL Server connection options
SQL Server support is currently in a Beta release. Also see SQL Server Additional Configuration.
service.yaml
string
Connection URI in the format
mssql://user:password@hostname:1433/database. Individual connection parameters take precedence over values in the URI.string
Database hostname. Required if not specified in
uri.number
default:"1433"
Database port.
string
Database username. Required if not specified in
uri or authentication.string
Database password. Required if not specified in
uri or authentication.string
Database name. Required if not specified in
uri.string
The database schema to replicate from.
object
Alternative authentication configuration, instead of
username and password.object
Additional replication settings.
number
default:"60"
Interval in seconds between source connection heartbeats. Must be between 5 and 60.
Convex connection options
Convex connection options
The Convex replicator is currently released as an experimental feature. See Convex source database setup.
service.yaml
string
required
The URL of your Convex deployment.
string
required
A deploy key for the Convex deployment, used to authenticate against the Convex Streaming Export API.
number
default:"1000"
Interval in milliseconds between polling for new changes.
number
default:"60000"
Timeout in milliseconds for requests to the Convex API.
storage
The PowerSync Service requires a storage database to store the data and metadata for buckets. You can use either MongoDB or Postgres for this purpose.The bucket storage database is separate from your source database.
string
required
The storage backend type:
mongodb or postgresql.number
default:"8"
Maximum number of connections to the storage database, per service process.
string[]
Block connections to any of these IP ranges. Include
local to block anything not in public unicast ranges.MongoDB Storage
service.yaml
string
required
Connection URI in the format
mongodb:// or mongodb+srv://. Standard connection options such as connectTimeoutMS, socketTimeoutMS, serverSelectionTimeoutMS, maxPoolSize and maxIdleTimeMS can be set as query parameters in the URI.string
Database name. Defaults to the database in the URI path.
string
Database username. Defaults to the username in the URI. The user should have
readWrite and dbAdmin roles.string
Database password. Defaults to the password in the URI.
number
default:"0.2"
Throttles the clearing of old bucket data after deploying a new sync configuration, by pausing between batches. The pause is proportional to the previous batch duration. Increase this to reduce the impact of clear operations on the storage cluster, or use
0 to clear as fast as possible. Must be between 0 and 20.string
Read preference for bulk checksum and bucket data reads:
primary, primaryPreferred, secondary, secondaryPreferred, or nearest. If unset, MongoDB driver defaults are used. This is an experimental option and may be removed in a future release.object
Experimental support for storing large bucket data chunks in S3-compatible object storage instead of MongoDB.
docker-compose file to configure a replica set as once-off operation:
Postgres Storage
Available since version 1.3.8 of thepowersync-service, you can use Postgres as an alternative bucket storage database.
service.yaml
uri, hostname, port, username, password, database, sslmode, cacert, client_certificate, client_private_key and tls_servername. In addition, batch limits can be tuned:
object
Limits for batch operations during replication. Increasing these limits can improve replication performance, at the cost of higher memory usage.
Database Setup
You’ll need to create a dedicated user and schema for PowerSync bucket storage. You can either:- Let PowerSync create the schema (recommended):
- Or manually create the schema:
Postgres Version Requirements
Separate Postgres servers are required for replication connections (i.e. source database) and bucket storage if using Postgres versions below 14.port
number
default:"8080"
The port on which the PowerSync API server will listen for connections. Can be specified as a number or string.
sync_config
Your Sync Streams (or legacy Sync Rules) configuration can be in a separate file (recommended) or inline in the main config. Thesync_config: key is used for both Sync Streams and Sync Rules.
string
Path to the Sync Streams/Sync Rules YAML file. Ensure the file is available at that path, e.g. in the same directory as your main config or on a mounted volume.
string
Inline Sync Streams/Sync Rules content as a string, as an alternative to
path.boolean
default:"true"
Whether to exit the process if there is an error parsing the Sync Streams/Sync Rules configuration.
The top-level
sync_rules key is a deprecated alias for sync_config. Use sync_config in new configurations.To verify that your Sync Streams are functioning correctly, inspect the contents of your bucket storage database.
MongoDB Example
If you are running MongoDB in Docker, run the following:client_auth
Authentication of client (application end user) connections is configured in theclient_auth section. For more details, see Client Authentication.
service.yaml
string | string[]
URI or array of URIs pointing to JWKS endpoints, used to fetch public keys for JWT verification.
object
Inline JWKS configuration, as an alternative or in addition to
jwks_uri.boolean
default:"false"
Enables Supabase authentication integration. JWKS details are derived from the Supabase connection. See Supabase Auth.
string
Legacy JWT secret for Supabase authentication (HS256 shared secret).
string[]
Valid audiences for JWT validation.
string[]
IP ranges to reject when resolving JWKS URIs. Include
local to block anything not in public unicast ranges.boolean
deprecated
When
true, blocks JWKS URIs that resolve to local network addresses. Use jwks_reject_ip_ranges instead.For production environments, we recommend using JWKS with asymmetric keys (RS256, EdDSA, or ECDSA) rather than shared secrets (HS256). Asymmetric keys provide better security through public/private key separation and easier key rotation. See Custom Authentication for more details.
api
string[]
Access tokens for the service’s admin API routes, provided by clients as a Bearer token. Authentication of these routes is disabled if no tokens are configured.
object
Performance and safety parameters for the API service.
telemetry
See Usage Reporting and Monitoring for details.boolean
required
When
true, disables sharing of anonymized usage metrics with the PowerSync telemetry service.number
Port on which Prometheus metrics will be exposed. When set, metrics will be available on this port for scraping.
string
Endpoint that anonymized telemetry is reported to. You typically do not need to change this.
healthcheck
Configures how health check status is exposed. See Health Checks for details on the available probes and endpoints.object
Mechanisms for exposing health check data. If this is not configured, the service defaults to legacy behavior for backwards compatibility (filesystem probes always enabled, plus HTTP probes depending on the service mode). When
probes is configured, each mechanism requires explicit opt-in.migrations
boolean
default:"false"
When
true, disables automatic storage database schema migrations on startup. Migrations can then be triggered externally by altering the container command.system
object
Service logging configuration.
metadata
object
Custom metadata key-value pairs (string values) for the service.
parameters
object
Global parameters (number, string, boolean or null values) that can be referenced in the sync configuration.