Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions configuration/auth/development-tokens.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
</Tab>

<Tab title="Self-Hosted">
For self-hosted setups, you can generate development tokens using the [powersync-service test-client](https://github.com/powersync-ja/powersync-service/tree/main/test-client):

Follow the steps below. Steps 1 and 2 configure signing keys and your PowerSync Service config; in Step 3 you can use the PowerSync CLI (recommended) or the [test-client](https://github.com/powersync-ja/powersync-service/tree/main/test-client) to generate the token.

<DevTokenSelfHostedSteps />
</Tab>
Expand All @@ -47,7 +46,7 @@

1. Open the [Sync Diagnostics Client](https://diagnostics-app.powersync.com)
2. Enter the generated development token at **PowerSync Token**.
3. Enter your PowerSync Service endpoint URL at **PowerSync Endpoint** unless already prepopulated.

Check warning on line 49 in configuration/auth/development-tokens.mdx

View check run for this annotation

Mintlify / Mintlify Validation (powersync) - vale-spellcheck

configuration/auth/development-tokens.mdx#L49

Did you really mean 'prepopulated'?
4. Click **Proceed**.
4. Wait for the syncing to complete and inspect the synced data in SQLite.

Expand Down
2 changes: 1 addition & 1 deletion configuration/source-db/setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@
| Database | Edition | Version | Min Service Tier |
| ---------------- | ------------------------------------------- | ------- | ------------------------------------------------------------------------------------- |
| SQL Server 2022+ | Standard, Enterprise, Developer, Evaluation | 16.0+ | N/A |
| Azure SQL\* | Database, Managed instance | N/A | Any service tier on vCore purchasing model. S3 tier and up on DTU purchasing model. See: [Azure SQL Database compute requirements](https://learn.microsoft.com/en-us/azure/azure-sql/database/change-data-capture-overview?view=azuresql#azure-sql-database-compute-requirements) |

Check warning on line 439 in configuration/source-db/setup.mdx

View check run for this annotation

Mintlify / Mintlify Validation (powersync) - vale-spellcheck

configuration/source-db/setup.mdx#L439

Did you really mean 'vCore'?

\* Azure SQL Database is always running on the latest version of the SQL Server DB Engine

Expand Down Expand Up @@ -469,7 +469,7 @@

- Read/Write permissions on the `_powersync_checkpoints` table
- Read permissions on the replicated tables
- `cdc_reader` role (grants access to CDC changetables and functions)

Check warning on line 472 in configuration/source-db/setup.mdx

View check run for this annotation

Mintlify / Mintlify Validation (powersync) - vale-spellcheck

configuration/source-db/setup.mdx#L472

Did you really mean 'changetables'?
- `SELECT` permission on the CDC schema (grants access to CDC metadata tables)
- `VIEW DATABASE PERFORMANCE STATE` (SQL Server and Azure SQL)
- `VIEW SERVER PERFORMANCE STATE` (SQL Server only)
Expand Down Expand Up @@ -615,7 +615,7 @@

2. **Polling Interval**: The frequency at which PowerSync polls the CDC change tables for changes. The default value is once every 1000ms. This can be changed by setting the `pollingIntervalMs` parameter in the PowerSync configuration.

<Warning>Configuration parameters for SQL Server like `pollingIntervalMs` and `pollingBatchSize` (see below) can currently only be [set when self-hosting](/intro/setup-guide#self-hosted-2) PowerSync. We are working on exposing these settings for SQL Server source database connections in the PowerSync Dashboard for PowerSync Cloud instances.</Warning>
<Warning>Configuration parameters for SQL Server like `pollingIntervalMs` and `pollingBatchSize` (see below) can currently only be set when self-hosting PowerSync (e.g. via your config file or the [PowerSync CLI](/tools/cli)). We are working on exposing these settings in the PowerSync Dashboard for PowerSync Cloud instances.</Warning>

### Memory Management

Expand Down
5 changes: 2 additions & 3 deletions intro/self-hosting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ The [PowerSync Service](https://github.com/powersync-ja/powersync-service) can b

<Note>
* Note that the [PowerSync Dashboard](https://dashboard.powersync.com/) is currently not available when self-hosting PowerSync.
* The PowerSync Open Edition is currently considered a beta release as it still requires more detailed documentation and guides. From a stability perspective, the Open Edition is production-ready. It uses the same codebase as our Cloud version. See [Feature Status](/resources/feature-status) for how we define beta releases.
* Please reach out on our [Discord](https://discord.gg/powersync) if you have any questions not yet covered in these docs.
</Note>

Expand All @@ -27,9 +26,9 @@ The quickest way to get a feel for the system is to run our example project on y

<Card title="GitHub - powersync-ja/self-host-demo" icon="github" href="https://github.com/powersync-ja/self-host-demo" horizontal />

## Local Development With Docker Compose
## Local Development

If you plan to self-host for development purposes only, see [Local Development](/tools/local-development) for how to easily do this using Docker Compose.
To run PowerSync locally, see [Local Development](/tools/local-development). The easiest path is the [PowerSync CLI](/tools/cli), which sets up a Docker Compose stack for you.


## Full Installation
Expand Down
602 changes: 384 additions & 218 deletions intro/setup-guide.mdx

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions maintenance-ops/self-hosting/diagnostics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ This API provides the following diagnostic information:
- Connections → Connected backend source database and any active errors associated with the connection.
- Active Sync Streams / Sync Rules → Currently deployed Sync Streams (or legacy Sync Rules) and its status.

## CLI

If you have the [PowerSync CLI](/tools/cli) installed, use `powersync status` to check instance status without calling the API directly. This works with any running PowerSync instance — local or remote.

```bash
powersync status

# Extract a specific field
powersync status --output=json | jq '.connections[0]'
```

## Diagnostics API

# Configuration

1. To enable the Diagnostics API, specify an API token in your PowerSync YAML file:
Expand Down
6 changes: 5 additions & 1 deletion maintenance-ops/self-hosting/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ sidebarTitle: Overview
import SelfHostDeploymentPlatformsCards from '/snippets/self-host-deployment-platforms-cards.mdx';


<Note>
The [PowerSync CLI](/tools/cli) provides commands that work alongside any running self-hosted instance: `powersync status`, `powersync validate`, `powersync generate schema`, `powersync generate token`. You don't need to have set up the instance with the CLI to use these.
</Note>

## Production Topics

Details for production self-hosted PowerSync deployments, including architecture/setup recommendations, security, health checks, maintenance, and monitoring.

<CardGroup>
<Card title="Deployment Architecture" icon="server" href="/maintenance-ops/self-hosting/deployment-architecture" horizontal />

<Card title="Update Sync Rules" icon="list-check" href="/maintenance-ops/self-hosting/update-sync-rules" horizontal />
<Card title="Update Sync Streams (Sync Config)" icon="list-check" href="/maintenance-ops/self-hosting/update-sync-rules" horizontal />

<Card title="Health Checks" icon="heartbeat" href="/maintenance-ops/self-hosting/healthchecks" horizontal />

Expand Down
49 changes: 35 additions & 14 deletions maintenance-ops/self-hosting/update-sync-rules.mdx
Original file line number Diff line number Diff line change
@@ -1,32 +1,53 @@
---
title: "Update Sync Streams"
sidebarTitle: "Update Sync Streams/Rules"
title: "Update Sync Streams (Sync Config)"
description: "How to update Sync Streams (or legacy Sync Rules) in a self-hosted PowerSync deployment"
---

There are two ways to update Sync Streams (or legacy Sync Rules) in a self-hosted deployment:
There are three ways to update your sync config in a self-hosted deployment:

1. **Config file** - Update your config and restart the service
2. **API endpoint** - Deploy at runtime without restarting
1. **CLI** — Edit your config and apply with `powersync docker reset`
2. **Config file** — Update your config and restart the service
3. **API endpoint** — Deploy at runtime without restarting

<Info>
During deployment, the existing version of your Sync Streams / Sync Rules continue serving clients while the new version is processed.
Clients seamlessly transition once [initial replication](/architecture/powersync-service#initial-replication-vs-incremental-replication)
completes.
During deployment, existing Sync Streams/Sync Rules continue serving clients while new sync config processes. Clients seamlessly transition once [initial replication](/architecture/powersync-service#initial-replication-vs-incremental-replication) completes.
</Info>

## Option 1: Config File (Recommended)
<Tip>
Run `powersync validate` in the CLI before deploying to catch errors in your sync config without applying changes.
</Tip>

Define Sync Streams (or legacy Sync Rules) in your `powersync.yaml` via a separate file (recommended) or inline.
## Option 1: CLI

See [Self-Hosted Instance Configuration](/configuration/powersync-service/self-hosted-instances) for the full config reference and [Sync Streams](/sync/streams/overview) (or legacy [Sync Rules](/sync/rules/overview)) for syntax.
If you set up PowerSync using the CLI (`powersync docker`), update your sync config and apply it without a full service restart:

<Steps>
<Step title="Edit Sync Config">
Update `powersync/sync-config.yaml` in your project directory.
</Step>
<Step title="Validate">
```bash
powersync validate
```
</Step>
<Step title="Apply">
```bash
powersync docker reset
```
This restarts the PowerSync Service and applies your updated sync config.
</Step>
</Steps>

## Option 2: Config File

Define your sync config in `powersync.yaml` either inline or via a separate file. See [Self-Hosted Instance Configuration](/configuration/powersync-service/self-hosted-instances) for the full config reference.

<Steps>
<Step title="Edit Config">
Update the `sync_config:` section in your `powersync.yaml`. The `sync_config:` key is used for both Sync Streams and Sync Rules:
<CodeGroup>
```yaml Sync Streams — Separate File (Recommended)
sync_config:

Check warning on line 50 in maintenance-ops/self-hosting/update-sync-rules.mdx

View check run for this annotation

Mintlify / Mintlify Validation (powersync) - vale-spellcheck

maintenance-ops/self-hosting/update-sync-rules.mdx#L50

Did you really mean 'sync_config'?
path: sync-config.yaml
```

Expand Down Expand Up @@ -64,13 +85,13 @@
docker compose restart powersync
```

Once the service starts up, it will load the updated Sync Streams / Sync Rules and begin processing them while continuing to serve the existing version until initial replication completes.
Once the service starts up, it will load the updated sync config and begin processing it while continuing to serve the existing config until initial replication completes.
</Step>
</Steps>

## Option 2: Deploy via API
## Option 3: Deploy via API

Deploy Sync Streams (or legacy Sync Rules) at runtime without restarting. Useful for quick iterations during development.
Deploy sync config at runtime without restarting. Useful for quick iterations during development.

<Warning>
The API is disabled when Sync Streams (or legacy Sync Rules) are defined in `powersync.yaml`.
Expand Down
46 changes: 29 additions & 17 deletions snippets/dev-token-self-hosted-steps.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
</Tab>
</Tabs>
</Step>
<Step title="Step 2: Update `config.yaml`">
Add the `client_auth` section to your `config.yaml`:
<Step title="Step 2: Update your config">
Add the `client_auth` parameter to your PowerSync config (e.g. `service.yaml`):

<Tabs>
<Tab title="RS256">
Expand Down Expand Up @@ -80,25 +80,37 @@
</Note>
</Step>
<Step title="Step 3: Generate a development token">
1. If you have not done so already, clone the [`powersync-service` repo](https://github.com/powersync-ja/powersync-service/tree/main)
2. Install the dependencies:
- In the project root, run the following commands:
Choose either the [PowerSync CLI](/tools/cli) (recommended) or the test-client:

<Tabs>
<Tab title="CLI (recommended)">
Apply your config changes (e.g. restart your PowerSync Service or run `powersync docker reset` if running locally with Docker), then run:

```bash
pnpm install
pnpm build
powersync generate token --subject=test-user
```
- In the `test-client` directory, run the following commands:

Replace `test-user` with the user ID you want to authenticate:
- If your Sync Streams/Rules data isn't filtered by user (same data syncs to all users), you can use any value (e.g., `test-user`).
- If your data is filtered by <Tooltip tip="Values such as user ID that are used to determine which data syncs to which user.">parameters</Tooltip>, use a user ID that matches a user in your database. PowerSync uses this (e.g. `auth.user_id()` in Sync Streams or `request.user_id()` in Sync Rules) to determine what to sync.
</Tab>

<Tab title="test-client">
1. If you have not done so already, clone the [`powersync-service` repo](https://github.com/powersync-ja/powersync-service/tree/main)
2. Install and build:
- In the project root: `pnpm install` and `pnpm build`
- In the `test-client` directory: `pnpm build`
3. Generate a token from the `test-client` directory, pointing at your config file:

```bash
pnpm build
node dist/bin.js generate-token --config path/to/config.yaml --sub test-user
```
3. Generate a new token by running the following command in the `test-client` directory with your updated `config.yaml` file:
```bash
node dist/bin.js generate-token --config path/to/config.yaml --sub test-user
```

Replace `test-user` with the user ID you want to authenticate:
- If your Sync Streams/Rules data isn't filtered by user (same data syncs to all users), you can use any value (e.g., `test-user`).
- If your data is filtered by <Tooltip tip="Values such as user ID that are used to determine which data syncs to which user.">parameters</Tooltip>, use a user ID that matches a user in your database. PowerSync uses this (e.g. `auth.user_id()` in Sync Streams or `request.user_id()` in Sync Rules) to determine what to sync.

Replace `test-user` with the user ID you want to authenticate:
- If your Sync Streams/Rules data isn't filtered by user (same data syncs to all users), you can use any value (e.g., `test-user`).
- If your data is filtered by <Tooltip tip="Values such as user ID that are used to determine which data syncs to which user.">parameters</Tooltip>, use a user ID that matches a user in your database. PowerSync uses this (e.g. `auth.user_id()` in Sync Streams or `request.user_id()` in Sync Rules) to determine what to sync.
</Tab>
</Tabs>
</Step>
</Steps>

Expand Down
Loading