This project is the base template for developing Electron applications using React.
Follow steps below in order to reproduce the same template.
Create a React App
npx create-react-app <your_app_name> --typescript
Note: Recent version of Electron builder has TS dependency. Hence, Typescript option is required.
Installing Dependencies
# yarn
yarn add cross-env electron-is-dev
yarn add --dev concurrently electron electron-builder wait-on
# npm
npm install --save cross-env electron-is-dev
npm install concurrently electron electron-builder wait-on
Create Electron App
Create a file named electron.js
in public folder and paste code below inside the file.
const electron = require("electron");
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
const path = require("path");
const isDev = require("electron-is-dev");
let mainWindow;
function createWindow() {
mainWindow = new BrowserWindow({ width: 900, height: 680 });
mainWindow.loadURL(isDev ? "http://localhost:3000":
`file://${path.join(__dirname, "../build/index.html")}`);
mainWindow.on("closed", () => (mainWindow = null));
}
app.on("ready", createWindow);
app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
});
app.on("activate", () => {
if (mainWindow === null) {
createWindow();
}
});
package.json
{
"description": "<your project description>",
"author": "<author of app>",
"build": {
"appId": "<com.your_app>"
},
"main": "public/electron.js",
"homepage": "./",
"scripts": {
"react-start": "react-scripts start",
"react-build": "react-scripts build",
"react-test": "react-scripts test --env=jsdom",
"react-eject": "react-scripts eject",
"electron-build": "electron-builder",
"release": "npm run build && electron-builder --linux --win --mac --x64 --ia32 --publish never",
"build": "npm run react-build && npm run electron-build",
"start": "concurrently \"cross-env BROWSER=none yarn react-start\" \"wait-on http://localhost:3000 && electron .\""
},
}
# ==== Runing ====
# yarn
yarn start
#npm
npm run start
# ==== Building ====
# yarn
yarn build
# build
npm run build
This template and the reproduction manual were taken from Devesu article on Medium. Link to Article
⚛️ Minimal zero dependency lazy load images solution with a simple React Hook for all images of an element
⚛️ Minimal "optimistic UI" pattern implementation with a React Hook
splash plugin for vue js
Simple and minimal resume builder with react and typescript
Speed up your component creation process with React.js. Modify contents, styles of the elements and click on export button to receive your component code with your custom configurations.
Manage the Werewolf easier than ever
A persian(jalaali, jalali, shamsi) date input with picker, which allows the user to type or select the date from the picker.
The pro version of notepad written in node.js-typescript with electron.js technology