- Published on
Using React with Electron - For Beginners!
I created this boilerplate after working on electron for one of my own apps. This is aimed at beginners and is a raw boilerplate built with create-react-app.
It contains some scripts i added to simplify usage for beginners. Do take a look!
This is an example electron/create-react-app application, and serves as an example of how to structure your project if you want to share pieces of your codebase between electron and react.
Usage
- Clone the repository
- cd into the directory and run
npm install - Delete git files
rm -rf .git
Development
- Run
npm startto start the react development server - After that, run
npm run start-electronin a different terminal to start the electron app
Build and package
- Run
npm run packageto compile react, copy files and then package your app - A new
distfolder will be created in the root of your project containing the executable files - NOTE: add
--macto thepostpackagescript besides--winif you are on a mac computer
Project structure
electron/: Code for the main Electron processsrc/react/: Code for the React renderer processsrc/shared/: Code shared between React and Electronpackage.json: Contains scripts for running the app in development, building it, and packaging it for production using electron-builder
Other posts on topic
- Bundle a React library with ParcelCreate a React library and bundle it with the new Parcel v2. Parts of Parcel are rewritten in Rust and that means it is ...Read →
- Understand how styled-components works by creating a cloneFirst article in a guide on how to build your own styled-components clone. Understand why it is necessary and how to sta...Read →
- React Internals (Part 3) - Fiber ArchitectureAn article explaining how Reacts latest Fiber architecture works and speeds up your websiteRead →
