Docs Menu

Docs HomeRealm

Device Sync - Flutter SDK

On this page

  • Synced Realms
  • What is Flexible Sync?

Device Sync automatically synchronizes data between client applications and an Atlas App Services backend application. When a client device is online, Sync asynchronously synchronizes data in the background between the device and your App Services backend.

The Flutter SDK only supports Flexible Sync. You must configure your App Services backend to use Flexible Sync.

Note

The Flutter SDK does not support Partition-Based Sync.

You can configure a realm to automatically synchronize data between many devices that each have their own local copy of the data. Synced realms use a different configuration than local-only realms and require an Atlas App Services backend to handle the synchronization process.

Applications can always create, modify, and delete synced realm objects locally, even when offline. Whenever a network connection is available, the Realm Flutter SDK opens a connection to an application server and syncs changes to and from other clients. The Atlas Device Sync protocol and server-side operational transforms guarantee that all fully synced instances of a realm see exactly the same data, even if some changes occurred offline and/or were received out of order.

Synced realms differ from non-synced local Realm Database in a couple of ways:

  • Synced realms attempt to sync changes with your backend App Services App, whereas non-synced realms do not.

  • Synced realms can be accessed by authenticated users, while non-synced realms have no concept of users or authentication.

You can copy data from a non-synced Realm Database to a synced realm, and vice versa, but you cannot sync a non-synced Realm Database.

When you select Flexible Sync for your App Services backend configuration, your client implementation must include subscriptions to queries on queryable fields. Flexible Sync works by synchronizing data that matches query subscriptions you maintain in the client application.

A subscription set contains a set of queries. Flexible Sync returns documents matching those queries, where the user has the appropriate permissions to read or write the documents. If documents match the query, but the client does not have the permission to read or write them, they do not sync to the client application.

You can form Flexible Sync queries using a limited subset of Realm Query Language. To learn more about which fields you can query, refer to the Queryable Fields documentation.

Subscription sets are based on a specific type of Realm object. To sync data for many types of Realm objects, you must have multiple subscriptions.

To use Flexible Sync in your client application, open a synced realm with a flexible sync configuration. Then, manage subscriptions to determine which documents to sync.

Before you can start syncing data from your client application using the SDK, you must enable Flexible Sync in the App Services backend.

To begin, refer to the backend documentation on enabling Device Sync.

Every write transaction for a subscription set has a performance cost. If you need to make multiple updates to a Realm object during a session, consider keeping edited objects in memory until all changes are complete. This improves sync performance by only writing the complete and updated object to your realm instead of every change.

←  Get the User Access Token - Flutter SDKAdd Device Sync to an App - Flutter SDK →
Share Feedback
© 2022 MongoDB, Inc.

About

  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2022 MongoDB, Inc.