PowerSync CLI on NPM
Install globally or run via npx
Source Code
PowerSync CLI repo on GitHub
Changelog
Changelog for the CLI
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. See Migrating From the Previous CLI if you used the older flow.
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:
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 cli.yamlrecords the instance ID along with the organization and project IDs. The organization and project IDs act as a cache: when both are present, the CLI uses them directly instead of looking them up from the instance, saving an API request. If they are missing, the CLI resolves them automatically from the instance ID. If they are present but incorrect for the instance, the CLI reports an error rather than overriding them.
Cloud Workflows
You can create instances, deploy and pull config, run all Cloud commands.Create a New Instance
1
Log in and scaffold
2
Edit config
Edit
powersync/service.yaml (name, region, replication, auth) and Sync Config; use !env for secrets.3
Create and link
--org-id=<org-id> if your token has multiple orgs.4
Deploy
--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.
A repeat pull does not overwrite your local files by default. If service.yaml or sync-config.yaml already exists, the CLI warns you and writes that file’s fetched version alongside it as service-fetched.yaml or sync-fetched.yaml, so your local edits survive and you can merge in the changes you want. Add --overwrite to replace the local files instead.
Preview a Deploy
Every deploy command accepts--dry-run, which shows what the command would do without changing the instance:
service.yaml sections that differ from the deployed config, and a diff of the Sync Config. Nothing is deployed.
Each command previews only what it deploys. powersync deploy service-config --dry-run reports the Sync Config as unchanged, and powersync deploy sync-config --dry-run reports the service config as unchanged.
If the instance is not provisioned yet, the dry run skips Sync Config validation, because that check runs against a running instance.
The service config summary lists section names only, because service.yaml holds connection strings and other secrets. To compare the full file, run powersync pull instance and diff the resulting service-fetched.yaml against your service.yaml.
Connections that pass a password with
secret always show replication as changed, because the value is sent again on every deploy.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>(writescli.yaml); later commands use that instance. - Or pass each time:
--instance-id, or setINSTANCE_IDin the environment.
The CLI resolves the instance in a fixed order: flags first, then
cli.yaml, then environment variables. 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
1
On the server
In your PowerSync instance config, define API tokens in
service.yaml:2
Link the CLI
cli.yaml with the API URL.3
Set the API key
In
cli.yaml set api_key: !env PS_ADMIN_TOKEN (or a literal value matching a server token), or set the PS_ADMIN_TOKEN environment variable. If both are set, the environment variable takes precedence.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, powersync compact) 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
The CLI prints the instance it is about to act on before
powersync deploy, powersync stop, powersync destroy, and powersync compact make any change, and at the start of powersync status. For a Cloud instance, the line shows the instance name with the instance, project, and organization IDs. For a self-hosted instance, it shows the API URL. Check this line before you confirm a destructive command.
Run 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. For self-hosted, API_URL can specify the PowerSync API base URL.
The job log records the target instance line, so you can see which instance a run changed. For pull request checks, run powersync deploy --dry-run to validate the config and preview the changes without deploying.
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:
Summary: Authenticate with
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.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