Navigation

Enable Development Mode

On this page

Overview

Development mode allows you to define and update your app’s schemas by syncing objects from a Realm SDK. While enabled, Realm does not enforce any data access rules and does not validate synced objects against existing schemas. Instead, Realm maps every synced object type to its own collection and automatically updates the collection schema to match the synced type.

Disable Development Mode for Production Apps

As the name suggests, development mode is an insecure development utility that is not suitable for production use. Make sure that you turn off development mode before you make your app accessible in a production environment.

Procedure

1
2

Select a Cluster to Sync

You can enable development mode sync for a single linked cluster in your application. Determine which cluster you want to use and then select it from the Select Cluster To Sync dropdown menu.

The cluster selection dropown menu
3

Choose a Target Database

While development mode is enabled, Realm maps every synced object type to its own collection in the linked cluster. The collections use the pluralized name of the object type and are located in a specific database.

Determine which database in the linked cluster you want to contain the synced data and then enter it into the Define a Database Name input.

The database selection dropown menu
4

Choose a Partition Key

The sync partition key is a field in every synced document that maps each document to a client-side realm. Sync rules apply at the partition level, so it is particularly important to consider your data model and access patterns. For more information on partition keys and how to choose one, see Partition Atlas Data into Realms.

Once you have decided which field to use, enter the field name into the Choose A Partition Key input.

The partition key selection dropdown menu
5

Turn On Development Mode

Click Turn Dev Mode On to enable development mode.

1

Update Your Local Application

To configure development mode through the CLI, you need an up-to-date application directory. To export the latest version of your app, run the following command from your shell:

realm-cli export --app-id=<Your App ID>
2

Select a Cluster to Sync

You can enable development mode sync for a single linked cluster in your application. If you have not yet linked the cluster to your application, follow the Link a MongoDB Atlas Cluster guide to link it before you continue.

Determine which cluster you want to use and then open its configuration file. Add the config.sync field with the following value:

{
  "config": {
    "sync": {
      "state": "enabled",
      "database_name": "<Target Database Name>",
      "partition": {
        "key": "<Partition Key Field>",
        "type": "<Partition Key Type>",
        "permissions": {
          "read": true,
          "write": true
        }
      }
    },
    ...
  },
  ...
}
3

Choose a Target Database

While development mode is enabled, Realm maps every synced object type to its own collection in the linked cluster. The collections use the pluralized name of the object type and are located in a specific database.

Determine which database in the linked cluster you want to contain the synced data and then specify the database name in config.sync.database_name:

{
  "config": {
    "sync": {
      "state": "enabled",
      "database_name": "myDevModeDatabase",
      "partition": {
        "key": "<Partition Key Field>",
        "type": "<Partition Key Type>",
        "permissions": {
          "read": true,
          "write": true
        }
      }
    },
    ...
  },
  ...
}
4

Choose a Partition Key

The sync partition key is a field in every synced document that maps each document to a client-side realm. Sync rules apply at the partition level, so it’s particularly important to consider your data model and access patterns. For more information on partition keys and how to choose one, see Partition Atlas Data into Realms.

Once you have decided which field to use, update config.sync.partition with the partition key field name in the key field and the partition key type in the type field.

{
  "config": {
    "sync": {
      "state": "enabled",
      "database_name": "myDevModeDatabase",
      "partition": {
        "key": "_partition",
        "type": "string",
        "permissions": {
          "read": true,
          "write": true
        }
      }
    },
    ...
  },
  ...
}
5

Enable Development Mode

You can turn development mode on and off by setting a boolean value for sync.development_mode_enabled in your app’s config.json file. To enable dev mode, set the value to true:

config.json
{
  ...,
  "sync": {
    "development_mode_enabled": true
  }
}
6

Deploy the Updated App Configuration

Now that you’ve configured development mode and specified that it’s enabled, you can deploy your changes to turn it on.

To deploy your changes, import your app configuration:

realm-cli import