Initializing Realm in React Native

Hi, I was wondering what’s the best practice on initializing realm within a react native project. I currently open it async in my App Provider and set the state to the realm and pass it around via the context api. I’ve seen examples where the realm is initializes in new Realm() instead of in the open() method. That realm is then passed around the application and used as needed instead of being stored in state. Is this an outdated approach or still usable and if so what would you reccomend

On this topic the React Realm Context package might be interesting to you: https://www.npmjs.com/package/react-realm-context

It’s still early stage, so any feedback would be highly appreciated.

1 Like