Skip to main content

Why Migrate?

PowerSync’s original Sync Rules system was optimized for offline-first use cases where you want to “sync everything upfront” when the client connects, so data is available locally if the user goes offline. However, many developers are building apps where users are mostly online, and you don’t want to make users wait to sync a lot of data upfront. This is especially true for web apps: users are mostly online, you often want to sync only the data needed for the current page, and users frequently have multiple browser tabs open — each needing different subsets of data.

The Problem with Client Parameters

Client Parameters in Sync Rules partially support on-demand syncing — for example, using a project_ids array to sync only specific projects. However, manually managing these arrays across different browser tabs becomes painful:
  • You need to aggregate IDs across all open tabs
  • You need additional logic for different data types (tables)
  • If you want to keep data around after a tab closes (caching), you need even more management

How Sync Streams Solve This

Sync Streams address these limitations:
  1. On-demand syncing: Define streams once, then subscribe from your app one or more times with different parameters. No need to manage arrays of IDs — each subscription is independent.
  2. Multi-tab support: Each subscription manages its own lifecycle. Open the same list in two tabs? Each tab subscribes independently. Close one? The other keeps working.
  3. Built-in caching: Each subscription has a configurable ttl that keeps data cached after unsubscribing. When users return to a screen, data may already be available — no loading state needed.
  4. Simpler, more powerful syntax: Stream queries support JOINs, CTEs, subqueries, and multiple queries per stream, and the syntax is closer to plain SQL. For example, parameter queries become inline subqueries, so you write a single query instead of separate parameters: and data: blocks.
  5. Framework integration: React hooks, Vue composables, TanStack Query, and Kotlin Compose extensions let your UI components automatically manage subscriptions based on what’s rendered.

Still Need Offline-First?

If you want “sync everything upfront” behavior (like Sync Rules), set auto_subscribe: true on your Sync Streams and clients will subscribe automatically when they connect.

Requirements

  • PowerSync Service v1.20.0+ (Cloud instances already meet this)
  • Latest SDK versions with Rust-based sync client (enabled by default on latest SDKs)
  • config: edition: 3 in your sync config

Migration Tool

You can generate a Sync Streams draft from your existing Sync Rules in two ways:
  1. Dashboard: In the PowerSync Dashboard, use the Migrate to Sync Streams button. It converts your Sync Rules into a Sync Streams draft that you can review before deploying.
  2. CLI: Run powersync migrate sync-rules to produce a Sync Streams draft from your current sync config.
The output uses auto_subscribe: true by default, preserving your existing sync-everything-upfront behavior so no client-side changes are required when you first deploy. Next steps: Review the draft, then deploy it (via the Dashboard or powersync deploy sync-config). After that, you can optionally migrate individual streams to on-demand subscriptions over time — remove auto_subscribe: true from specific streams and update client code to use the syncStream() API where it makes sense for your app.

Stream Definition Reference

Migration Examples

Global Data (No Parameters)

In Sync Rules, a “global” bucket syncs the same data to all users. In Sync Streams, you achieve this with queries that have no parameters. Add auto_subscribe: true to maintain the Sync Rules behavior where data syncs automatically on connect. Sync Rules:
Sync Streams:
Without auto_subscribe: true, clients would need to explicitly subscribe to these streams. This gives you flexibility to migrate incrementally or switch to on-demand syncing later.

User-Scoped Data

Sync Rules:
Sync Streams:

Data with Subqueries (Replaces Parameter Queries)

Sync Rules:
Sync Streams:

Client Parameters → Subscription Parameters

Sync Rules used global Client Parameters:
Sync Streams use Subscription Parameters, which are more flexible — you can subscribe multiple times with different values:

Parameter Syntax Changes

Client-Side Changes

After updating your sync config, update your client code to use subscriptions:
See Client-Side Usage for detailed examples.