Using Expo and Realm React Native with expo-dev-client
Rate this tutorial
Yes, it sounds like clickbait, but it's true. If you want to build a full application that uses TypeScript, just type in your terminal:
After either of these two, change to the directory containing the project that has just been created and start the iOS or Android app:
This will create a Expo app. That is, you'll see
androidfolders in your project and this won't be a managed Expo app, where all the native details are hidden and Expo takes care of everything. Having said that, you don't need to go into the
androidfolders unless you need to add some native code in Swift or Kotlin.
Once launched, the app will ask to open in
ReactRealmJSTemplateApp, not in Expo Go. This means we're running this nice, custom, dev client that will bring us most of the Expo Go experience while also working with Realm React Native.
We can install our app and use it using
yarn ios/android. If we want to start the dev-client to develop, we can also use
This template is a quick way to start with Realm React Native, so it includes all code you'll need to write your own Realm React Native application:
- It adds the versions of Expo (^44.0.6), React Native (0.64.3), and Realm (^10.13.0) that work together.
- It also adds
@realm/reactpackages, to make the custom development client part work.
- Finally, in
app, you'll find sample code to create your own model object, initialize a connection with Atlas Device Sync, save and fetch data, etc.
Use the ⌘D keyboard shortcut when your app is running in the iOS Simulator, or ⌘M when running in an Android emulator on macOS, and Ctrl+M on Windows and Linux.
|Android Debug Menu||iOS Debug Menu|
As this is an Expo app, we can also show the Expo menu by just pressing
mfrom terminal while our app is running.
So, right now, you have to choose:
- Have Expo + Realm working out of the box.
- Or start your app using Realm React Native+ Hermes (not using Expo).
In this post, we've shown how simple it is now to create a React Native application that uses Expo + Realm React Native. This still won't work with Hermes, but watch this space as Realm is already compatible with it!