Docs Menu

Docs HomeRealm

Bootstrap with Expo - React Native SDK

On this page

  • Prerequisites
  • Setup
  • Initialize the Template
  • Explore The File Structure
  • Build and Run the Application
  • Deploying Your Application

The Realm Expo template provides a fully working React Native application that you can use to bootstrap your app development project with Realm. This documentation covers how to initialize and work with the Realm Expo template.

The Realm Expo template uses:

  • Expo, a framework to develop, build and deploy React Native applications quickly.

  • @realm/react, an NPM package that provides an easy-to-use API to perform common Realm operations, such as querying or writing to a realm and listening to realm objects.

Next, before you initialize the template, you must install the expo cli by running the following command:

npm install -g expo-cli

To initialize a React Native application using the Realm Expo template use the Expo CLI.

Use expo init with the flag --template @realm/expo-template to initialize a React Native application using the Realm Expo Template.

Run the following command in your terminal:

expo init MyAwesomeRealmApp --template @realm/expo-template

The relevant files are as follows:

A typescript file that defines a Task object schema and returns a RealmProvider and the hooks.
The entry point to the application, which contains methods to create, update, and delete tasks. The RealmProvider component wraps around the App component, providing your entire application with access to the realm.
A React component that gets a list of Task objects from the realm and renders each object as a TaskItem component.
A React component that displays the task's description, a checkbox to toggle the task's completion status, and a button to delete the task.

To run your application on an Android emulator, run the following command from your application root:

expo run:android

To run your application on an iOS simulator, run the following command from your application root:

expo run:ios

When you run the commands above, the Expo dev-client will start automatically. If you close your Expo dev-client and want to restart it without waiting for the native build process again, you can simply run:

expo start --dev-client

However, if you made any changes to the native code, you will have to re-run expo run:ios or expo run:android to rebuild your native iOS/Android app.

To deploy your application, we recommend using the Expo Application Services (EAS), a suite of deeply integrated cloud services for Expo and React Native apps. EAS allows you to compile and sign your App, upload your app to the Apple App Store or Google Play Store with a single CLI command, and push bug fixes or small changes directly to app users.

Alternatively, read the Expo Distribution Overview guide to learn how to create native builds, deploy to app stores, avoid common app store rejections, and manage different release environments.

←  Quick Start - React Native SDKWork with Realm Files - React Native SDK →
Share Feedback
© 2023 MongoDB, Inc.


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