Navigation

Enable Hosting

On this page

Overview

You need to enable static hosting for your application before you can upload and access content. You can allow static hosting from the Realm UI or by importing an application directory that enables hosting in its configuration file. Select the tab below that corresponds to the method you want to use.

Procedure

Select a tab below to see instructions on enabling static hosting for the corresponding method.

1
2

Enable Hosting

On the Hosting configuration page, click Enable Hosting. MongoDB Realm will begin provisioning hosting for your application.

Note

It may take a few minutes for MongoDB Realm to finish provisioning hosting for your application once you’ve enabled it. You can upload content to MongoDB Realm immediately, but you will need to wait for provisioning to complete before MongoDB Realm serves your files.

1

Export Your Realm Application

To enable static hosting for your application with realm-cli you need to export an application directory.

You can export your application from the Import/Export App tab of the Deploy page in the Realm UI, or by running the following command from an authenticated instance of realm-cli:

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

Enable Hosting in the Application Configuration

In config.json, set the value of hosting.enabled to true then save the file.

"hosting": { "enabled": true }
3

Import the Updated Application Configuration

Once you have enabled hosting in config.json, you can import the directory into your application. Navigate to the root of the application directory and run the following command:

realm-cli import

MongoDB Realm will begin provisioning hosting for your application after you successfully import the application directory.

Note

It may take a few minutes for Realm to finish provisioning hosting for your application once you’ve enabled it. You can upload content to Realm immediately, but you will need to wait for provisioning to complete before Realm serves your files.