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

is it possible to be used with Flutter? #225

Open
codeitlikemiley opened this issue Apr 19, 2024 · 5 comments
Open

is it possible to be used with Flutter? #225

codeitlikemiley opened this issue Apr 19, 2024 · 5 comments

Comments

@codeitlikemiley
Copy link

I know flutter have a Flutter Rust Bridge,

But i wanna know if it is possible to use Flutter instead of Swift UI or Jetpack Compose ....

@charypar
Copy link
Member

It should be possible, but there are a few hurdles we haven't overcome, mostly because the Flutter use-case seems somewhat weak - if you're going to build UI in Flutter, you could adopt the architecture and build in Dart. That said, I'm sure there are hybrid approaches where it would be valuable.

We're interested in supporting Flutter, but to be fully transparent - we don't have a gread deal of experience with Flutter or much need for it, so we'd love to find a champion for that integration to help get it working.

Flutter integration has first been discussed in #78, can we continue the discussion in that other issue, please?

@dancixx
Copy link

dancixx commented May 13, 2024

@charypar same question in case of react-native, is it possible to use it? I went through the documentation and examples but I am not sure whether is it possible to use or not.

@charypar
Copy link
Member

@dancixx In theory, yes. 🙂

In practice, getting it through the build tooling might be a bit challenging. I see two approaches that should work:

  1. attempt to get a wasm build working in RN - quick google found https://github.com/cawfree/react-native-webassembly, which may be an option
  2. link Crux in like you would in a native app, and use the RN bridging to surface the Crux API to your TypeScript code. You could still use the generated TypeScript types, you could even keep the native bridge really minimal and deserialize the data in TypeScript.

We don't have examples of this setup, because it seems like a somewhat redundant stack. The primary target for Crux are the native UI frameworks in order to get a native, idiomatic user experience. If you're building in React Native already, you might as well build the whole app in TypeScript, there isn't a great deal to gain from having Crux involved (other than the magic of Rust 🦀), and it should be entirely possible to replicate the Elm-like architecture with something Redux-like and 90% of the testability benefits.

Now with that said, I can certainly imagine a scenario in which for example you'd want to use Crux to support a platform not supported by React Native yet (let's say a CLI, or reusing the code ona server, for the lack of a better example), or you might want a gradual migration path from React Native to Crux with Swift UI and Jetpack Compose, in which case one of the two approaches above should work - ultimately the Crux core is quite a straightforward library, from the perspective of the shell.

Curious about your use case, would you mind sharing some more context?

@dancixx
Copy link

dancixx commented May 13, 2024

@charypar my main motivation is using rust everywhere if its possible. I am really big fan of rust and on other hand I love to use react-native to make mobile apps. It is not real native but using native components what is much better like flutter canvas solution and more time efficient like native solutions, and if u are take care about performance it almost the same like native, and futhermore the new arch is really promising in case of performance. There are some examples how is it possible to use rust code in react-native but it requires some c binding so it doesnt worth it that way. Btw this project is awesome and there growing and promising rust based cross platform solutions like Xilem, Ribir, Tauri etc. which can give us alternatives.

@charypar
Copy link
Member

Ah, well that makes perfect sense to me, Rust is indeed amazing 🙂 If you do try getting Crux to work with RN and hit any barriers, feel free to open issues, link to some half-working code, or join us on Zulip and we'll try and help where we can.

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

No branches or pull requests

3 participants