Getting started with realm in react native

React Native

Home » Blog » Javascript » React Native » Getting started with realm in react native

Realm is object database management system. In this post you will find step by step method for installing the realm in your react project. Currently all the react project by default upgraded to expo but expo did not include the realm in their project. yet. So we have to eject from the expo and start our project as a pure react native project.

First create a app with expo

Create a blank project and inside that directory run the eject command

It asks for various options then choose the first option ” React Native: I’d like a regular React Native project.” After this provide the app name and the package name. It will take some minutes and we will have a pure react native application.

It will have the package.json file similar to this . Since at the time of writing this post the current version is 0.57 for the react-native and it has a breaking changes to I modified it and downgraded it to version 0.55

Now we have to install the realm package and link it to our react native code. while installing the realm package there came a permission issue so I recommend you to see my another post about ‘Install realm package in react-native app’.

It will going to show the realm package inside the node_modules library. After installing the realm if we tried to run the project in our android emulator/device we might sometime face the issue ‘Cannot find entry file index.js.

At the time of writing this post using eject option from expo is not a good option and a lot of things break on the way. It is showing error since the expo made App.js file but when you see the file it is looking for the index.js file which is causing this issue

So first rename the App.js file of the root directory to the index.js file and modify the code inside the file as

Make sure you write your package name correctly in <yourpackagename> . It will going to be the same which you entered during the eject expo process.

Finally run your project

During the compilation the realm will be compiled successfully.

About Author