Follow these instructions to set up and run the project.
Ensure you have the following installed on your machine:
- Node.js (v14.x or later)
- Yarn (v1.x or later) or npm (v6.x or later)
-
Create a Next.js application:
Using Yarn:
yarn create next-app
Using npm:
npx create-next-app@latest
-
Install development dependencies:
Using Yarn:
yarn add --dev electron electron-builder concurrently
Using npm:
npm install electron electron-builder concurrently --save-dev
-
Install
electron-serve
:Using Yarn:
yarn add electron-serve
Using npm:
npm install electron-serve
-
Update
package.json
to include the following:{ "main": "main/main.js", "author": "Md Habibor Rahman Hira", "description": "Boreal software company", "scripts": { "dev": "concurrently -n \"NEXT,ELECTRON\" -c \"yellow,blue\" --kill-others \"next dev\" \"electron .\"", "build": "next build && electron-builder" } }
-
Create
next.config.js
:const nextConfig = { output: "export", images: { unoptimized: true } }; module.exports = nextConfig;
-
Create
main/main.js
:const { app, BrowserWindow } = require("electron"); const path = require("path"); let appServe; if (app.isPackaged) { (async () => { appServe = (await import('electron-serve')).default({ directory: path.join(__dirname, "../out") }); })(); } const createWindow = () => { const win = new BrowserWindow({ width: 800, height: 600, webPreferences: { preload: path.join(__dirname, "preload.js") } }); if (app.isPackaged) { appServe(win).then(() => { win.loadURL("app://-"); }); } else { win.loadURL("http://localhost:3000"); win.webContents.openDevTools(); win.webContents.on("did-fail-load", (e, code, desc) => { win.webContents.reloadIgnoringCache(); }); } }; app.on("ready", () => { createWindow(); }); app.on("window-all-closed", () => { if (process.platform !== "darwin") { app.quit(); } });
-
Create
main/preload.js
:const { contextBridge, ipcRenderer } = require("electron"); contextBridge.exposeInMainWorld("electronAPI", { on: (channel, callback) => { ipcRenderer.on(channel, callback); }, send: (channel, args) => { ipcRenderer.send(channel, args); } });
-
Create
electron-builder.yaml
:appId: "app.Borealsoftwarecompany.com" productName: "Boreal software company" copyright: "Copyright (c) 2023 Boreal software company" win: target: ["dir", "portable", "zip"] icon: "resources/icon.ico" linux: target: ["dir", "appimage", "zip"] icon: "resources/icon.png" mac: target: ["dir", "dmg", "zip"] icon: "resources/icon.icns"
-
Install
electron-updater
:Using Yarn:
yarn add electron-updater
Using npm:
npm install electron-updater
-
Update
package.json
to include the following for building and publishing:{ "build": { "appId": "com.Borealsoftwarecompany.myappname", "files": [ "!node_modules" ], "nsis": { "oneClick": false, "perMachine": true }, "productName": "myappname", "win": { "icon": "/resources/icon.png", "publish": [ "github" ] }, "linux": { "icon": "/resources/icon.png", "publish": [ "github" ] } }, "electronBuilder": { "asar": true, "compression": "maximum" }, "repository": "https://github.com/mdhira-ai/batchwork", "license": "MIT", "publish": { "provider": "github", "releaseType": "release" } }
-
Development:
yarn dev
or
npm run dev
-
Build:
yarn build
or
npm run build
- Md Habibor Rahman Hira - Initial work - Habib Software Industry
This project is licensed under the MIT License - see the LICENSE file for details.
- Special thanks to the Electron and Next.js communities for their invaluable resources and support.