Navigation

Get Started with Sync

Overview

Realm Sync enables you to share data across devices, between Realm clients and a synced MongoDB Atlas cluster.

Enable Sync

You can enable Sync on any Realm app you have created.

MongoDB Version 4.4 Required

In order to use Realm Sync, your Atlas cluster must use MongoDB version 4.4. When setting up your cluster, select MongoDB 4.4 from the dropdown menu under Additional Settings.

Note

Realm syncs all data from collections with a defined Realm Schema in your Atlas cluster. If you do not specify a field in your schema, Realm will not sync that field to the clients.

1
2

Decide Whether to Use Development Mode

The Sync panel presents you with two tabs: Configuration and Development Mode. The tab that you should select depends on whether you want to define your object models in client-side code or prefer to use a server-side configuration.

Select the Configuration tab if you want Realm to generate the client-side object model code for you based on your schemas. MongoDB Realm can generate schemas for you based on data already in your cluster, or you can define them yourself.

Select the Development Mode tab if you would rather define and modify your object model in client-side code.

3

Configure Sync

Follow the instructions in the Realm UI to configure sync for your cluster.

  1. Select a Cluster to Sync: Realm Sync applies to the entire cluster. Specify which cluster you want to sync in the dropdown.
  2. Define a Database Name (Development Mode Tab Only): If you opted to use Development Mode, Realm needs to know which database in your cluster to use for new collections it creates for Sync. Specify that database name in the input field.
  3. Choose a Partition Key: Specify which field to use to determine which realm each object belongs to. See Partition Atlas Data into Realms.
  4. Define Permissions (Configuration Tab Only): Select a template from the dropdown or enter your read and write sync rule in the input boxes.
4

Save the Configuration and Enable Sync

On the Configuration tab, click Enable Sync to enable sync.

On the Development Mode tab, click Turn Dev Mode On to enable sync with Development Mode.

5

Sync Data from a Client

Now that you have enabled Realm Sync, you can open a synced realm using a client SDK to read and write synced data. See the client guide for your SDK:

Summary

  • You can enable Realm Sync on your linked cluster for any Realm app you have created.