Support Electron in Expo
complete
Aubrey Alexander
Electron has a lot of the same capabilities as mobile. Bluetooth, battery, lots of capibilities. See https://electronjs.org/docs
With support for react-native-web, it'd really just take a set of additional wrappers for desktop electron capibilities, so you could have a single set of wrappers for things like, say, notifications, and they'd route to that platforms functionality.
It'd be great to have compilable desktop applications built with expo as well so it truly was a way to develop for any platform, including mac and windows with installable apps.
Evan Bacon
complete
We've release an "official flow" for using Electron with Expo for web. It'll also make its way into the SDK 36 docs.
There are a lot of great points and counter points in this thread so I'll quickly address some of them.
> Why Electron?
We're currently investigating
react-native-windows
but that'll be a huge project. We want to support many different options and give developers the ability to choose which stack they want to use. This means having at least some Electron support, Microsoft is also working on improving Electron a lot so I imagine it'll get much better in the near future. That said, I think we'd much rather have a solid native solution so we won't be pouring too much time into Electron.
We created
expo/electron-adapter
so that anyone who wants to use Electron has to opt-in to the workflow. This is important because it'll prevent extra node modules from being installed in every project and the CLI. > not as much as need for such an expo flow either
- Think of this more like a dead-simple way to use react-native-webwith Electron and Webpack.
- Expo SDK does have some native module overlap with Electron, things like FileSystem for instance.
Thiago
Evan Bacon: Can expo/electron-adapter be used in bare workflow projects?
Evan Bacon
Thiago: yes, electron is part of expo web. Web support is fully agnostic of the expo client and managed workflow
J
Jonathan Stevens
Evan Bacon:
Is it possible to have a Platform-specific extension for electron. I've been encountering which could be solved with a simple "file.electron.js" method. (if not, will be happy to log error reports)
Otto
How does proton-native and react-native-electron fit into this picture? I wonder why proton-native doesn't seem to use the standard <View> component like all other RN apps?
Aubrey Alexander
Petr Peller
I don't think Expo should spent time building a wrapper around Electron since you can use Electron API directly.
Simple support for .electron.js should be enough and that's not a request for Expo.
Scott Pritchard
React-native-windows and react-native-macos exist already.
Electron is a chromium wrapper, and I don't believe it is a good scope for expo.
J
Jhang Chaussy
Scott Pritchard: I agree with you.
Aubrey Alexander
Scott Pritchard: That's fair. I'm not sure how far out Expo is on brining support for react-native-windows and react-native-macos apps. I thought this might be a smaller step before than, basically piggybacking on the work they already committed to for react-native-web, and just offering electron wrappers for their device-specific functionality the same way that they offer react native wrappers for native iOS and Android functionality, like gps, etc.
I totally get there's a lot of electron hate out there, but Desktops offer a lot of interesting capabilities, some of which are in parallel with functionality mobile supports. If the overall goal is a single hybrid codebase that can build to multiple platforms, taking the concepts they already have wrapped for mobile and having a solution to point to the desktop equivalents is probably work they'll likely end up doing regardless of end platforms.
All and all, while Electron might not be a good fit for you, it's probably at lest a good thing to think about and a step that might take far less time than integrating actual native-built implementations into windows from a single hybrid-code base.
I'm I am wrong and that's easy, than I'll take the native versions. If if that ends up being year(s) out to get into Expo natively, then it might at least be worth considering this as a half-step forward.
Jonas Lund
Aubrey Alexander: I think there's 3 issues with Electron, the first is the obvious that you have this huge web browser platform just to run a few "components" (RN core is far far smaller).
Secondly we have that Electron handles "native" access in a slightly weird way with a multiprocess system (you have a renderer UI process and the "system" Node process doing filesystem,etc access). This means that the porting Expo API's to Electron would take a bit of work since it behaves quite differently.
Third, on top of this Electron packaging/installation is a large piece that'd need to go on top of regular packaging making things a tad more convoluted.
MS is putting quite a bit of work into react-native-windows (they're ditching the first effort to join a new branch with the rest of the regular RN codebase for better compat) and being built directly (not indirectly like Electron) on Node making bindings should be quick, and with both Project Catalyst and react-native-macos the native options will hopefully be fairly faithful to the core RN and thus have smaller diffs compared to Electron.
I've worked with a React+Electron codebase recently and it's also quite easy to get working compared to "raw" RN so there's not as much as need for such an expo flow either imho (You can check out bootstrapping systems that exist today like https://github.com/electron-react-boilerplate/electron-react-boilerplate and add react-native-web and you've got most of the generic parts already)