Skip to main content
PowerSync Sync Rules allow developers to control which data gets synchronized to which devices (i.e. they enable dynamic partial replication).

Introduction

We recommend starting with our Sync Rules from First Principles blog post, which explains on a high-level what Sync Rules are, why they exist and how to implement them. The remainder of these docs dive further into the details.
Sync Streams available in Early AlphaSync Streams are now available in early alpha! Sync Streams will eventually replace Sync Rules and are designed to allow for more dynamic syncing, while not compromising on existing offline-first capabilities.Key improvements in Sync Streams over Sync Rules include:
  • On-demand syncing: You define Sync Streams on the PowerSync Service, and a client can then subscribe to them one or more times with different parameters.
  • Temporary caching-like behavior: Each subscription includes a configurable TTL that keeps data active after your app unsubscribes, acting as a warm cache for recently accessed data.
  • Simpler developer experience: Simplified syntax and mental model, and capabilities such as your UI components automatically managing subscriptions (for example, React hooks).
We encourage you to explore Sync Streams for new projects, and migrating to Sync Streams once they are in Beta.

Defining Sync Rules

Each PowerSync Service instance has a Sync Rules configuration where Sync Rules are defined using SQL-like queries (limitations and more info here) combined together in a YAML file. The Service uses these SQL-like queries to group data into “sync buckets” when replicating data from your backend source database to client devices.