Docs Menu

Quick Start with Expo - React Native SDK

On this page

  • Overview
  • 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. Read the Realm React documentation to learn more about working with it.

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.

The relevant files are as follows:

File
Purpose
Task.ts
A typescript file that defines a Task object schema and returns a RealmProvider and the hooks.
App.ts
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.
TaskList.tsx
A React component that gets a list of Task objects from the realm and renders each object as a TaskItem component.
TaskItem.tsx
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.
Tip
See also:

Once you have explored your file structure, we recommend reading the Realm React documentation to learn how to work with Realm React.

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 the application builds, you will see something similar to the following image:

Realm Expo Template on an iOS Simulator

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 Realm 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 with Sync - React Native SDKUse Realm React →
Give Feedback
© 2022 MongoDB, Inc.

About

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