Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web support #26

Open
maxkrieger opened this issue Apr 9, 2021 · 29 comments
Open

Web support #26

maxkrieger opened this issue Apr 9, 2021 · 29 comments

Comments

@maxkrieger
Copy link

maxkrieger commented Apr 9, 2021

Since Realm already has a JS client, would it be easy enough to add a web compatible variant to this package?

@richard457
Copy link

This would be awesome

@blagoev
Copy link
Contributor

blagoev commented May 14, 2021

We are certainly interested in supporting Flutter Web as a platform but it will require web assembly support and our Core team is exploring the various options we have. This is still at very early stages of research so we can't do any commitments currently

@cedvdb
Copy link

cedvdb commented May 22, 2021

wouldn't js with indexedDB be enough ? Last I checked the js client was just allowing graphql queries

@calvintam236
Copy link

wouldn't js with indexedDB be enough ?

I think the point is to have a cross-platform database on Flutter (android, ios, web and other supported platforms).

@markbreuss
Copy link

Would love to see web support as well!

@hmbenhaim
Copy link

Hi, any updates on this one?

@dotjon0
Copy link

dotjon0 commented Oct 23, 2022

From a local persistent DB perspective; not sure how beneficial this is for Flutter Web as persistent local databases in web browsers are usually not a great approach from a data security perspective...

@hmbenhaim
Copy link

hmbenhaim commented Oct 23, 2022

From a local persistent DB perspective; not sure how beneficial this is for Flutter Web as persistent local databases in web browsers are usually not a great approach from a data security perspective...

From what I understand the web support in general of realm is not local db just a sync from the cloud and it's available for js just ask to add it to flutter web

https://www.mongodb.com/docs/realm/web/

@ajonno
Copy link

ajonno commented Jan 31, 2023

they should add support for GraphQL subscriptions

@JakobStadlhuber
Copy link

Any updates? web assembly is now in a further stage with flutter web since the last keynote a couple weeks ago.

@nirinchev
Copy link
Member

Support for web assembly is not on our short-term roadmap. As @blagoev said, we are interested in eventually supporting it as a platform and are doing some preliminary work there, but we don't currently expect this to materialize in something user-facing before the end of 2023.

If you would like to use App Services in a web assembly project, the recommendation is to use GraphQL or the Data API which are both accessible using a simple http client or via a 3rd party package, such as graphql_flutter.

@JakobStadlhuber
Copy link

I understand. I just wanted to make it clear that there is a big opportunity in the growing flutter community for you.
Developing once for Web, App, and the Desktop Client with realm/app service as a backend/data solution sounds amazing. We will probably use it anyway but we have to write a separated codebase just for the web, because there is no web support with flutter realm. I hope you see the big potential with really just one codebase for companies/startups....

@nirinchev
Copy link
Member

We are aware of it and are definitely interested in catering to the needs of businesses that would like to share a codebase between their native and web apps. The main blocker here is that the database as well as the sync layer is written in C++ (in order for us to share it across all supported platforms). Web Assembly imposes certain restrictions/has some peculiarities when it comes to IO and multithreading that require significant work to support. We're working on it and making some progress there, but I wanted to be upfront about the timelines so that you folks can make the best design choices for the architecture of your project. If you're looking to ship something in the next 3-6 months, it would be a mistake to wait for WebAssembly support in the Flutter SDK. If you're working on a huge project that will ship in 2024 or later, then definitely reach out to your account executive (if using any of our paid services) and they should be able to work with you and share more precise timelines as well as relay your requirements to the engineering team.

@realrk95
Copy link

Now that Flutter 3.10 is released and supports WASM, would it be possible to use Realm on web?

@minikin
Copy link

minikin commented May 17, 2023

@realrk95 It has limited support. I believe adding support for the web is still a challenging task.

@nielsenko
Copy link
Contributor

For the interested (in case you missed it) there is a preview in the realm-js SDK for for proper Realm support including full Atlas Device Sync. This is based on compiling realm-core to wasm with emscripten. Take note that it has significant limitations.

NOTE: It is only for javascript, not Dart.

@aehlke
Copy link

aehlke commented Aug 29, 2023

@nielsenko not sure where's best to give this feedback, but the next absolute game changer would be to figure out how to connect other wasm efforts such as SwiftWASM into this new realm-js work such that Swift code (or other langs which Realm supports) can be used for both mobile and web including the Realm usage. JS is great for cross-platform, but there are many Swift / native app developers who are looking for cross-plat solutions too and this brings us closer to that. Thanks

@nielsenko
Copy link
Contributor

@aehlke I'm not familiar with SwiftWASM, but feel free to open a feature request in https://github.com/realm/realm-swift

@zs-dima
Copy link

zs-dima commented Aug 31, 2023

@nirinchev @blagoev
You can see nice solution that uses Wasm SQLite or IndexedDB depends on web browser:
Drift library: https://drift.simonbinder.eu/web/#storages

@nielsenko
Copy link
Contributor

nielsenko commented Aug 31, 2023

@zs-dima I'm well aware of the work of Simon Binder (@simolus3). I used to use Drift (or moor as it was called back then) a lot. Another database that support web is isar by Simon Choi (@simc). I can highly recommend both, if synchronisation is not important to you, and you need web support now.

@zs-dima
Copy link

zs-dima commented Aug 31, 2023

@nielsenko thanks a lot for the answer, I cannot reccommend ISAR alghthough. It has critical issues with isolates for example.
isar/isar#1112
isar/isar#1199
. . .
In the same time community and all my projects are happy with Drift.
Sorry for the offtopic.

@nielsenko
Copy link
Contributor

@zs-dima Please observe https://www.mongodb.com/community-code-of-conduct. I can't speak for @nirinchev, but I stand by my word.

@nirinchev nirinchev mentioned this issue Oct 28, 2023
@rodrigoreal
Copy link

Any update on this?

@nirinchev
Copy link
Member

When we have an update, we will be sure to post it in the issue.

@juppdes
Copy link

juppdes commented Mar 13, 2024

Sorry for my ignorance, but why doesn't it work on web apps?

@nirinchev
Copy link
Member

The Realm database is built in C++ and the features it uses - particularly around filesystem access - are not available in the web. The Realm Flutter SDK is wrapping the C++ database to expose ergonomic API to read/write data from dart/flutter apps, but the platforms we support are limited by the platforms the native database supports.

@nielsenko
Copy link
Contributor

To elaborate on @nirinchev's answer.

We would need to compile realm-core (or actually librealm_dart.so which includes the former) to WASM. Some ground work has been done to this end, but we are not done.

One complication is that realm uses mmap'ed IO, which is not supported by the WASM runtimes of the browsers. We either need to

  • wait for the WASM memory-control proposal to be ratified and implemented in a majority of runtimes,

  • rewrite significant parts of realm-core to avoid the strict dependency on mmap, or

  • forego persistence (as we do in the JS web sync preview)

Also, we are using dart:ffi to call into native code. Dart FFI is not supported with Flutter Web (yet). This means we will have to manually create a JS interop based binding instead.

Add on top of this that some browsers still don't even support WasmGC - which is pre-requisite for compiling flutter code to WASM. This means we would have to support compiling to javascript, just to run in Safari. Or any browser on iOS, as they all forced to use WebKit (except in the EU as of iOS 17.4). Which again will require some work-around regarding the dreaded 53 bit integers.

This is just a lot of risky external dependencies, and/or a ton of work that has to be prioritized among other stuff. That said, we are well aware that this is the most upvoted feature in the repo. So stay tuned, but be very patient 🙏 ..

@Dararii
Copy link

Dararii commented Sep 27, 2024

After the depreciation announcement of Atlas Device SDK by MongoDB weeks ago, which also affects this Realm Flutter SDK,

  • Will this library still be actively maintained?
  • Will this feature still be developed in the future?

If someone has the answer please help. I could not find any better answer on the deprecation page other than "The on-device database will continue to exist as an open-source project."

We need clarification because we do not want to waste investment in our project if Realm will be dead soon. Thanks.

@nirinchev
Copy link
Member

MongoDB will not be actively contributing to the project, but if someone from the community would like to work on this feature, we'd be willing to accept PRs and facilitate new releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests