Deploy Changes with Realm CLI


You can deploy changes to your Realm app with Realm CLI by importing an application directory with configuration files that define the updated app.




Prepare the Application Directory

Export your application to a local application directory. Alternatively, create a new application directory that contains a config.json file with your application’s app_id.

  "app_id": "<Your Application ID>"

Add or Update Application Entities

Add sub-directories and configuration files for any new entities you’re importing, or update the values in existing entity files. Every configuration file must conform to its configuration file schema.


Authenticate a MongoDB Atlas User

To import or update a Realm app with realm-cli, users must authenticate with MongoDB Atlas using an API Key.

realm-cli login --api-key="<my api key>" --private-api-key="<my private api key>"

Run the Import Command

Use the realm-cli import to deploy your changes:

realm-cli import --strategy=merge

Import Strategy

The --strategy flag indicates how you want Realm to handle configuration files that are missing or duplicated compared to the currently deployed version of your application. For more information, see import strategies.

If you want to upload static assets to Realm Hosting, include the static assets in the /hosting/files directory and specify the --include-hosting option:

realm-cli import --strategy=merge --include-hosting

If you want to upload external dependencies, include your archived node_modules in the /functions directory and specify the --include-dependencies option:

realm-cli import --strategy=merge --include-dependencies

Review and Confirm Import Diff

Before committing the import, realm-cli will show you a diff of the changes that will be made to your application. Review the diff to ensure that all changes are correct then confirm the import.

After successfully importing your application, Realm will automatically deploy a new version of your app and update your local application directory to match the new deployment.