The most common question people ask is how to get Electron to run on their device, and there are a lot of different options out there.
In this post, we’ll walk through the steps needed to build a simple Electron app using React, but we’ll also cover the differences between Electron and React Native, the popular JSX-based development framework.
React Native is the new, open-source framework developed by Facebook to bring native development to mobile devices.
React provides a lightweight, declarative way to build applications, but is not limited to building web apps.
React does not have any built-in APIs or tools for building apps.
Instead, it relies on third-party libraries like Babel, Webpack, and Electron.
React uses React Native to build its native apps, and React itself does not use React Native at all.
React native is currently only supported on iOS devices, and only supports the latest version of the latest mobile platforms, such as iOS 10.
React also does not support React Native-specific features like React Native View, which allows developers to embed React components in a view.
React’s native development process requires you to use a native compiler, like ESLint, as well as a developer tools package like Babel.
If you’re unfamiliar with how to use ESLint or Babel, we recommend you read the React Native Tutorial and React Dev Tools documentation.
To build the React app, we used the React-Native-native-cli tool.
To learn more about React Native and the React ecosystem, check out our React Native article.
If we use npm run build to run this command, React will build all the dependencies and build our app in the background.
To see our React app running in the foreground, run npm run watch –watch .
The watch command will periodically restart React to build the app and watch the process for changes.
To run the watch command and see what React is building, run node watch ./scripts/react-native/js-src.js –watch and the output should be a file called ./scripts/.
This is the same file that we created earlier with npm run dev.
This file contains all the React files that have been created by React and will be loaded into our app.
To watch React, we use the watch node ./tests/react.js and watch ./tests.js for a total of 30 seconds.
You can pause or resume the watch process by using the pause or resume commands.
If the React process fails to restart after a certain amount of time, then npm run refresh will be executed to restart the process.
If React is running successfully, the React file is written to the filesystem.
The source files will be written to /src/nodejs , so we need root privileges to write to the /src directory.
To test that our React files are writing to /sdcard/, we can run npm test ./scripts/**/app.js .
If you are having issues, you can check the output with npm ls -al /sdcards/src to see the contents of the /sd cards directory.
If your app is running and working correctly, you should see something like this in your console: You can deploy your app to production by using npm run prod , but we recommend using npm deploy instead.
After deploying, you’ll have access to your app’s local directory, as long as it is running properly.
After you’ve deployed your app, you will be able to access it using the app id, the name of the app, and its version.
To deploy a new app, simply run npm deploy –release –apps ./scripts/* –debug .
For more information about deploying React Native applications, check our React Developers guide.
If all went well, you now have an Electrons app on your device that can be deployed to the Internet with React Native.
If your Electrons site is down or not working, it’s a good idea to take a look at your Electron site’s status page and make sure everything is working properly.
If it’s not, it could be because the Electron server is down, or the Electrons