- DATE:
- AUTHOR:
- PowerSync Product Team
Prioritized Sync: Ensure Critical Data Syncs First
Overview
We’re excited to introduce Sync Bucket Priorities, a new feature that optimizes sync performance by allowing you to control the order in which data syncs. This ensures that critical data syncs first, improving your app's responsiveness and user experience.
Use case example
Imagine a task management app where you want users to see their lists before individual tasks load. You can specify bucket priorities in your sync rules as follows:
bucket_definitions:
user_lists:
priority: 1
parameters: select id as list_id from lists where user_id = request.user_id()
data:
- select * from lists where id = bucket.list_id
user_todos:
priority: 2
parameters: select id as todo_id from todos where list_id in (select id from lists where user_id = request.user_id())
data:
- select * from todos where list_id = bucket.todo_id
Here, lists sync first, ensuring they appear in the UI before todos load in the background.
On the client-side, you can then use the extended waitForFirstSync(priority)
and SyncStatus.statusForPriority(priority)
API methods to wait for specific priority levels to complete before proceeding with UI updates. Following the above example, you can ensure that lists (priority 1) are fully synced before rendering the UI, improving the user experience by preventing incomplete data from being displayed.
Availability
This feature is now available in the Beta channel for Cloud instances, and was released in version 1.7.1 of the PowerSync Service for self-hosted deployments.
It will be released to the Stable channel for Cloud instances in the next few days following some soak-testing.
The new client-side APIs were introduced in the following versions of our client SDKs:
Kotlin Multiplatform v1.0.0-BETA26
Support in our other React Native, JavaScript/Web and Swift SDKs is on the way and will be released soon.
Get Started
Read the full documentation on Prioritized Sync.
Reference our example implementations.
Join our Discord Community and share your feedback!