Skip to main content

PowerSync CLI on NPM

Install globally or run via npx

Source Code

PowerSync CLI repo on GitHub

Changelog

Changelog for the CLI
The PowerSync CLI lets you manage PowerSync Service instances, deploy sync config (your Sync Streams or Sync Rules), generate client schemas, run diagnostics, and more. It is distributed as the powersync npm package.
The CLI is currently in beta. We recommend it for new and existing projects.
For a full step-by-step flow using the CLI, use the Setup Guide: choose the CLI (Cloud) or CLI (Self-Hosted) tab in steps 2–5 to configure your instance, connect the source database, deploy sync config, and generate development tokens.
The CLI was overhauled in version 0.9.0. The redesign is based on this design proposal.
Main improvements:
  • Project-based config — A powersync/ directory in your repo holds service.yaml and sync-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 configure to scaffold a local PowerSync stack with no manual setup.
  • Better validationpowersync validate checks your config before deploy and reports errors with line and column numbers.
  • Config Studiopowersync edit config opens a built-in editor with schema validation, autocomplete, inline errors, and more. See the Config Studio README.
  • Browser loginpowersync login opens a browser to create or paste a PAT and stores it; in CI use PS_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 via npx:

Authentication (Cloud)

Cloud commands require a PowerSync personal access token (PAT). Interactive login (recommended for local use):
You can open a browser to create a token in the PowerSync Dashboard or paste an existing token. The CLI stores the token in secure storage when available (e.g. macOS Keychain), or in a config file after confirmation. CI and scripts: Set the PS_ADMIN_TOKEN environment variable. The CLI uses PS_ADMIN_TOKEN when set; otherwise it uses the token from powersync login.
To clear stored credentials: powersync logout.

Config Files

The CLI uses a config directory (default powersync/) with YAML files:

Developer Notes

  • Use the !env tag for secrets, e.g. uri: !env PS_DATABASE_URI (or !env VAR::number / !env VAR::boolean for types).
  • Edit files in your IDE, then run powersync validate and powersync deploy. For schema validation and !env support in your editor, run powersync configure ide; or run powersync edit config to 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, use password: secret: !env VAR to supply the value from an environment variable at deploy time; after the first deploy you can switch to secret_ref: default_password to reuse the stored secret. Details
  • cli.yaml records 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

Add --org-id=<org-id> if your token has multiple orgs.
4

Deploy

Use --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):
Then edit 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> (writes cli.yaml); later commands use that instance.
  • Or pass each time: --instance-id, or set INSTANCE_ID in 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

1

On the server

In your PowerSync instance config, define API tokens in service.yaml:
2

Link the CLI

Writes 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.
When you already have a running PowerSync API:
Use --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.
Then use the same commands as any self-hosted instance (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).
For the full Docker workflow, all flags (--database, --storage, --remove, --remove-volumes), and how the template layout and init scripts work, see Docker usage in the CLI repo. Run powersync docker --help for command options.

Common Commands

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: keep service.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.

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:
Otherwise, upgrade to the latest powersync npm package and follow the mapping below. 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 login may 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