DATE:
AUTHOR:
PowerSync Product Team
PowerSync Service Flutter SDK React Native SDK Kotlin Multiplatform SDK JavaScript/Web SDK Swift SDK

Prioritized Sync: Ensure Critical Data Syncs First

DATE:
AUTHOR: PowerSync Product Team

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

Get Started

Powered by LaunchNotes