The CLI is currently in beta. We recommend it for new and existing projects.
What changed in 0.9.0?
What changed in 0.9.0?
Main improvements:
- Project-based config — A
powersync/directory in your repo holdsservice.yamlandsync-config.yaml, so you version and review config with your app code. - Self-hosted support — Most commands work against any linked instance, PowerSyncCloud and self-hosted. You can also use
powersync docker configureto scaffold a local PowerSync stack with no manual setup. - Better validation —
powersync validatechecks your config before deploy and reports errors with line and column numbers. - Config Studio —
powersync edit configopens a built-in editor with schema validation, autocomplete, inline errors, and more. See the Config Studio README. - Browser login —
powersync loginopens a browser to create or paste a PAT and stores it; in CI usePS_ADMIN_TOKEN. - Plugins — npm-based plugin system (OCLIF); install with
powersync plugins install <package>or build with@powersync/cli-core. - Open source — Source and advanced docs are in the PowerSync CLI repo.
Installation
Install globally or run vianpx:
Authentication (Cloud)
Cloud commands require a PowerSync personal access token (PAT). Interactive login (recommended for local use):PS_ADMIN_TOKEN environment variable. The CLI uses PS_ADMIN_TOKEN when set; otherwise it uses the token from powersync login.
powersync logout.
Config files
The CLI uses a config directory (defaultpowersync/) with YAML files:
| File | Purpose |
|---|---|
service.yaml | Instance configuration: name, region, replication connection, client auth |
sync-config.yaml | Sync Streams (or Sync Rules) |
cli.yaml | Link file (written by powersync link); ties this directory to an instance |
Developer notes:
- Use the
!envtag for secrets, e.g.uri: !env PS_DATABASE_URI(or!env VAR::number/!env VAR::booleanfor types). - Edit files in your IDE, then run
powersync validateandpowersync deploy. For schema validation and!envsupport in your editor, runpowersync configure ide; or runpowersync edit configto open Config Studio (built-in web-based editor). - To use one config directory across multiple instances (e.g. dev, staging, prod), see the CLI usage docs on configuring multiple instances.
- For Cloud secrets in
service.yaml, usepassword: secret: !env VARto supply the value from an environment variable at deploy time; after the first deploy you can switch tosecret_ref: default_passwordto reuse the stored secret. Details
Cloud workflows
You can create instances, deploy and pull config, run all Cloud commands.Create a new instance
Edit config
Edit
powersync/service.yaml (name, region, replication, auth) and sync config; use !env for secrets.--directory=<path> for a different config folder.
Use an existing instance (pull)
Pull config from an instance that already exists (e.g. created in the Dashboard):service.yaml and sync-config.yaml as needed, run powersync validate, and powersync deploy. Run powersync pull instance again (no IDs if already linked) to refresh from the cloud.
Run commands without local config
To run commands (e.g.powersync generate schema, powersync status) against an instance managed elsewhere (e.g. Dashboard):
- Link once:
powersync link cloud --instance-id=<id> --project-id=<id>(writescli.yaml); later commands use that instance. - Or pass each time:
--instance-id,--project-id, and--org-idwhen the token has multiple orgs. Or setINSTANCE_ID,PROJECT_ID,ORG_IDin the environment.
The CLI resolves instance and linking context in a fixed order: flags take precedence, then environment variables, then values in
cli.yaml. For the full resolution order and how to set up multiple instances (e.g. dev, staging, prod), see supplying linking information for Cloud and self-hosted commands in the CLI usage docs.Self-hosted workflows
Support is limited: you link to an existing PowerSync API and run a subset of commands. The CLI does not create, deploy to, or pull config from your server; you manage the server and its config yourself. For local development, use Docker to run a PowerSync Service (and optional DB/storage) in containers.Authenticate
Scaffold and link (no Docker)
When you already have a running PowerSync API:--directory=<path> for a different config folder.
Supported commands (self-hosted)
Only these commands apply to self-hosted instances:powersync status, powersync generate schema, powersync generate token, powersync validate, powersync fetch instances (scans current directory for folders with cli.yaml).
Cloud-only commands (powersync deploy, powersync pull instance, powersync fetch config, powersync destroy, powersync stop) do not apply.
Docker (local development)
Run a PowerSync Service (and optional DB/storage) in containers on your machine—no remote server.powersync status, powersync generate schema, etc.). To stop: powersync docker stop (add --remove to remove containers, --remove-volumes to reset so init scripts run again). For a clean setup: powersync docker reset (stop and remove, then start).
Common commands
| Command | Description |
|---|---|
powersync login | Store PAT for Cloud (interactive or paste token); use PS_ADMIN_TOKEN in CI |
powersync logout | Remove stored token |
powersync init cloud | Scaffold Cloud config directory |
powersync init self-hosted | Scaffold self-hosted config directory |
powersync configure ide | IDE: YAML schema validation and !env support |
powersync link cloud --project-id=<id> | Link to existing Cloud instance |
powersync link cloud --create --project-id=<id> | Create new Cloud instance and link |
powersync link self-hosted --api-url=<url> | Link to self-hosted instance |
powersync pull instance --project-id=<id> --instance-id=<id> | Download Cloud config to local files |
powersync deploy | Deploy full config to linked Cloud instance |
powersync deploy service-config | [Cloud] Deploy only service config |
powersync deploy sync-config | [Cloud] Deploy only sync config |
powersync validate | Validate config and sync rules/streams |
powersync edit config | Open Config Studio (Monaco editor) |
powersync status | Instance diagnostics (Cloud and self-hosted) |
powersync generate schema --output=ts --output-path=schema.ts | Generate client schema |
powersync generate token --subject=user-123 | Generate development JWT |
powersync fetch instances | List Cloud and linked instances |
powersync fetch config | [Cloud] Print instance config (YAML/JSON) |
powersync migrate sync-rules | Migrate Sync Rules to Sync Streams |
powersync destroy --confirm=yes | [Cloud] Permanently destroy instance |
powersync stop --confirm=yes | [Cloud] Stop instance (restart with deploy) |
powersync --help or powersync <command> --help for flags. Full command reference in the CLI repo.
Deploying from CI (e.g. GitHub Actions)
You can automate sync config (and full config) deployments using the CLI in CI. Use the config directory as the source of truth: keepservice.yaml and sync-config.yaml in the repo (with secrets via !env and CI secrets), then run powersync deploy (or powersync deploy sync-config).
Secrets: Set PS_ADMIN_TOKEN to your PowerSync personal access token. If the workflow does not use a linked directory, also set INSTANCE_ID and PROJECT_ID (and ORG_ID only if your token has multiple organizations). For self-hosted, API_URL can specify the PowerSync API base URL.
GitHub Actions Demo
Example: deploy sync config on push to main
Migrating from the previous CLI
If you used the older PowerSync CLI (e.g.npx powersync init to set token and org/project, then powersync instance set, powersync instance deploy, etc.), the new CLI uses a different flow. Version 0.9.0 and above are not backwards compatible with 0.8.0. If you are not ready to migrate, you can stay on the old CLI:
| Previous CLI | New CLI |
|---|---|
npx powersync init (enter token, org, project) | powersync login (token only). Then powersync init cloud to scaffold config, or powersync pull instance --project-id=... --instance-id=... to pull an existing instance. |
powersync instance set --instanceId=<id> | powersync link cloud --instance-id=<id> --project-id=<id> (writes cli.yaml in config directory). Or use --directory for a specific folder. |
powersync instance deploy (interactive or long flag list) | Edit powersync/service.yaml and powersync/sync-config.yaml, then powersync deploy. Config is in files, not command args. |
powersync instance config | powersync fetch config (output as YAML or JSON with --output). |
| Deploy only sync rules | powersync deploy sync-config. |
powersync instance schema | powersync generate schema --output=... --output-path=... (and/or powersync status for diagnostics). |
| Org/project stored by init | Pass --org-id and --project-id when needed, or use powersync link cloud so they are stored in powersync/cli.yaml. For CI, use env vars: PS_ADMIN_TOKEN, INSTANCE_ID, PROJECT_ID, ORG_ID (optional). |
powersync login (or PS_ADMIN_TOKEN in CI). Use a config directory with service.yaml and sync-config.yaml as the source of truth. Link with powersync link cloud or powersync pull instance, then run powersync deploy or powersync deploy sync-config. No more setting “current instance” separately from config—the directory and cli.yaml define the target.
Additional documentation (CLI repository)
More information is available in the PowerSync CLI repository.| Resource | Description |
|---|---|
| CLI README | Getting started, Cloud and self-hosted overview, and full command reference with all flags. |
| General usage | How the CLI works: local config vs linking, resolution order (flags → env vars → cli.yaml), and configuring multiple instances (e.g. dev/staging/prod with separate directories or !env in cli.yaml). |
| Docker (local development) | Self-hosted Docker workflow, configure/start/stop/reset, database and storage modules, and template layout. |
| Config Studio (editor) | Built-in Monaco-powered editor for service.yaml and sync-config.yaml (powersync edit config), schema validation, and local development. |
| Examples | Sample projects initialized with the CLI (e.g. Cloud pull, self-hosted Postgres, self-hosted Supabase). |
Known issues and limitations
- When secure storage is unavailable,
powersync loginmay store the token in a plaintext config file after explicit confirmation. - Self-hosted: the CLI does not create or manage instances on your server, or deploy config to it; it only links to an existing API and runs a subset of commands (status, generate schema/token, validate). The sole exception is Docker: it starts a local PowerSync Service (and optional DB/storage) in containers on your machine for development — not a remote or production instance.
- Some validation checks require a connected instance to complete successfully; validation of an unprovisioned instance may show errors that resolve after the first deployment.
Reference
npm: powersync
Package and version history
Manage your access tokens
Create or revoke tokens in the PowerSync Dashboard
PowerSync CLI Repo
Source code, usage docs, Docker usage, and examples