Below is an example README for your boilerplate:
A starter kit for building cross-platform desktop applications using Electron and React. This boilerplate is designed to load your application via the file:// protocol rather than an HTTP server, making it fast and simple to set up and avoiding creating unnecessary HTTP services in the user's computer.
- Electron & React Integration: Seamlessly build desktop applications with a modern React front-end.
- No HTTP Server: The app is loaded directly from the file protocol.
- React Router Included: Handle routing within your React application.
- Multi-Platform Build Commands: Easily package your app for macOS, Linux, and Windows.
- Build Tasks with Gulp: Automated build tasks for JavaScript, CSS, and assets.
-
Clone the repository:
git clone https://github.com/jesobreira/electron-react-boilerplate.git cd electron-react-boilerplate
-
Install dependencies:
npm install
src/
: Contains your React application code, HTML, CSS, and assets.main.js
: Entry point for the Electron main process. Modify this to adjust global app settings like menus and window titles.package.json
: Contains application metadata (name, version, etc.) and build scripts.gulpfile.js
: Defines tasks for building, copying, testing, and starting the application.
- All your React components, pages, and routes live in the
src/
folder. - Use React Router to manage navigation within your app.
- Edit HTML files located in
src/
as needed. These files serve as the container for your React app.
- **Main Process (
main.js
):**Customize the Electron global settings here:- Menu: Adjust or create custom menus.
- Window Title: Set the default title or update window settings.
- Other Global Settings: Tweak settings such as window size, behavior, and more.
-
**
package.json
:**Update the following fields to match your app’s identity:name
,version
,description
- Other custom fields that you may want to include for your build process are included in the
scripts
section of package.json.
-
**Logos & Icons:**Replace the logo files located in
assets/images/
with your own assets. These are referenced in the build commands:logo.icns
for macOSlogo.png
for Linuxlogo.ico
for Windows
The project uses several npm scripts defined in package.json
along with Gulp tasks to streamline development and production builds.
-
Start the App in Development Mode:
This command builds the app (copying assets, compiling JS/CSS) and starts Electron.
npm start
-
Testing:
Run tests after building the project:
npm test
-
Build Task:
Run Gulp’s build tasks (for JS and CSS) without starting Electron:
npm run build
-
Release Task:
This command builds your project and then runs the Electron Builder to package your app for distribution:
npm run release
You can create builds for different platforms using these commands:
-
macOS:
npm run build-mac
-
Linux:
npm run build-linux
-
Windows:
npm run build-windows
Additional commands for creating installers:
-
Debian Package:
npm run build-debian
-
DMG for macOS:
npm run build-dmg
Make sure to update the configuration files and assets (like icons) referenced in these commands to match your app’s branding.
This project is licensed under the MIT License.
Happy coding! If you have any issues or feature requests, please open an issue on the repository.