Migrate mobile MERN stack app to Realm

I currently have a mobile app that is built connected to MongoDB Atlas. I’m trying to understand what is the benefit of using Realm and how difficult it would be to change my mobile app to connect to Realm. Can someone explain the benefits?

Hi @Matthew_Harris - welcome to the community forum!

Where to start on the advantages of using Realm? This video gives a good intro that might help. For a mobile app, the biggest single benefit is that the app can read and write data even when offline - Realm Sync will then make sure that all copies in the mobile app(s) and Atlas match once you reconect.

Moving databases is never a trivial task, but working with an OODBMS (Realm) is much closer to working with an object database (MongoDB) and so it’s one of the simpler migrations you could attempt.

Andrew, thanks for your reply. Are there any resources on this? Blog post etc? If MongoDB has invested so much in Realm, what is the use if I can’t understand specific use cases and have a resource on how to do a transfer where Realm and MongoDb work together for a better mobile experience. Thanks!

I’m not aware of any guides for migrating a mobile app from a MongoDB driver to realm, but I can look into it. Is your app using a mobile database such as core data or SQLite?

In terms of advantages of making the move, for me these are some of the most significant:

  • Rather than fetching data from Atlas over the internet every time the app needs a bit of data, it’s stored locally in Realm -> less latency + you can still read/write the data when you’re not connected to the network
  • MongoDB Realm can be used to control which users access what data (i.e. you can set rules to say that the mobile app will only sync data that’s owned by the user or their team)
  • You can have Realm manage user registration and authentication
  • If your mobile app needs to work with other cloud services (e.g., AWS S3) then this can be done via your backend Realm service – so no need to handle AWS credentials, etc. in your frontend app
  • You can implement serverless functions in your backend Realm app (think AWS Lambda but for large numbers of quick operations)
  • You have a GraphQL API that web apps, etc. can use to access the same data

In many cases, it removes the need for an application server as MongoDB Realm + Atlas handles all of the backend work (your mobile app just works with the Realm SDK).

The docs have a lot more details.

We have posts on building mobile apps with Realm - you can find a bunch here.

If you have specific questions then this is a good forum to ask.

Thanks for the response. We are using MongoDB atlas as the core data. A few things I like that you are talking about - the serverless functions - we are considering moving our API to lambda, but this could be another option. Are there easy ways to create these functions somewhere then deploy them into the realm environment (ssh or some cmd)? I guess essentially CI/CD. Is there someone you can put me in touch with at Mongo that can go deeper into discussions around this? Thanks, Matt