Device Sync Integration with React Native Application

I need your expertise on device sync integration with a mobile app! Here’s the scoop:

I currently have a Node.js application powered by MongoDB Atlas for its database. Now, I’m venturing into building a mobile application that must seamlessly work offline and sync with the MongoDB database when the app reconnects to the internet.

Here’s a bit more detail:

  • The MongoDB cluster will receive data from both the Node.js application and the mobile app.
  • One of the critical features of the Node.js application is to maintain customer account balances, recording all invoices and payments made by a customer along with their balance.

Here are my specific concerns:

  1. How does device sync handle conflicts if a transaction is made for a client from both the Node.js application and the mobile app? Will I need to implement custom logic to fix the balance?
  2. Can anyone provide reference documentation or resources for integrating MongoDB Realm with an existing database?
  3. The nodejs app is using JWT for the authentication, can I use the same JWT for the mobile app authentication?

Your insights, advice, and recommendations would be immensely valuable as I navigate this integration. Thank you in advance for your help and expertise!

Hi Bachir,

This is the exact use case for Atlas Device Sync. Answering each of your specific concerns:

How does device sync handle conflicts if a transaction is made for a client from both the Node.js application and the mobile app? Will I need to implement custom logic to fix the balance?

Atlas Device Sync automatically handles conflicts. The details of how they’re handled are outlined here https://www.mongodb.com/docs/atlas/app-services/sync/details/conflict-resolution/. You shouldn’t need to write any custom conflict resolution code.

Can anyone provide reference documentation or resources for integrating MongoDB Realm with an existing database?

Atlas Device Sync does work out of the box with your existing data in Atlas. When you set up Sync you configure which cluster you’d like to sync your mobile app with. https://www.mongodb.com/docs/atlas/app-services/sync/configure/enable-sync/

There’s also a handful of YouTube videos on MongoDB’s YouTube page which you can also refer to.

There are also some tutorials for the different Mobile App platforms we support available. These apps will do most of the configuration for you and help you start experimenting with Atlas Device Sync sooner.

The nodejs app is using JWT for the authentication, can I use the same JWT for the mobile app authentication?

You can integrate JWT auth with Atlas App Services. There are many auth providers. To integrate with your existing JWT auth system you can follow the instructions for Custom JWT authentication.

Please let me know if you have any further questions or concerns!

Best of luck building out your app :rocket:

Yaseen