realm-js
realm-js copied to clipboard
React Native - web support
Goals
To write a React Native app for iOS, Android and also Web using a single SDK.
Expected Results
The realm package to support also web platform.
Actual Results
Currently I find difficult to design React Native app with realm for all three platforms (Android, iOS and Web) as the web platform requires realm-web package that provides significantly different API than the realm package.
This results in added complexity in designing the code in the way to support both SDKs.
Are there any plans to expand the support of React Native SDK also for web? If not, what are the reasons that it cannot be supported?
the web platform requires
realm-webpackage that provides significantly different API than the realm package.
Except for the Realm Database, the two SDKs should be aligned. If they're not, this would be considered a bug and we would love to know. Would you be able to share examples of how the experience of using one package is different from the other?
Are there any plans to expand the support of React Native SDK also for web? If not, what are the reasons that it cannot be supported?
The Realm Database is written around a codebase called Realm Core, written in C++. Historically that has been hard to compile and run on web, but with the rise of WebAssembly (WASM) we're investigating our options. If this is your use-case, please reach out to Ian Ward via his email listed in this blog post on our developer community.
Thank you for your quick reply with the explanation and I apologize for not being more specific. I meant the Realm database API as for mobile platforms the SDK provides the concept of live objects together with reactiveness based on listeners on individual objects and results. On the other hand the web SDK provides MongoDB API which is significantly different concept and hence requires to add complexity to design the code the way it can work with both SDKs - this results also in added cost of maintenance and QA.
I understand the technological challenges with the native Realm database when it comes to the web support, however, in my opinion, for supporting the web would be enough not having the fully featured offline-first database but just to have the same API "mimicking" the same concept (live objects + reactiveness) to access the data online so the full cross-platform benefit of React Native can be met. Also, I find the React Native API much more easy-to-use and intuitive than the MongoDB or GraphQL approach.
I understand that the key feature of the Realm database is that it runs offline and it's performant which is very important for mobile devices but when it comes to the web I personally don't see these same requirements as important.
We're also working on a react-native app that will support web.
I'm using https://docs.mongodb.com/realm-sdks/js/latest/Realm.MongoDBCollection.html#watch to simulate reactiveness, but I would rather have the same interface as well, so I don't have to write the logic twice. (and the objects are not "live") On the web, offline-first isn't as important but it could be a nice feature to have.
@maxencehenneron @altick Thank you for your request for Realm Sync for web. As @kraenhansen outlines, we are investigating different options. To help us, we would love to hear more about your use cases.
@kneth Our goal is to use react-native-web to build the website using code from the react-native app. We'd like to reuse as much code as possible so having a unified interface to interract with a synced realm on web and mobile would definitely help, even if it uses direct online mongodb queries in the background (usually websites do not need an offline mode)
We have a similar goal as well as similar issues to the ones described above: We'd like to use react-native-web and leverage realm-web for its web counterpart. However, due to realm-web's API being different compared to realm-js (on React Native), it would mean that we'd have to write code differently for the web platform.