What is Electron Forge?
Electron Forge is the official toolchain for building Electron applications. It handles everything: scaffolding, building, packaging, code signing, and publishing — with a single unified API.
No more juggling electron-builder, electron-packager, and electron-notarize separately.
Quick Start
npm init electron-app@latest my-app
cd my-app
npm start
You have a working desktop app with hot reload in under 30 seconds.
The Forge API
Programmatic Build
const { api } = require("@electron-forge/core");
// Package your app
await api.package({
dir: "./my-app",
platform: "darwin",
arch: "arm64",
});
// Create distributable (DMG, EXE, DEB)
await api.make({
dir: "./my-app",
platform: "darwin",
arch: "arm64",
targets: ["@electron-forge/maker-dmg"],
});
Forge Configuration
// forge.config.js
module.exports = {
packagerConfig: {
name: "My App",
icon: "./assets/icon",
appBundleId: "com.mycompany.myapp",
osxSign: {},
osxNotarize: {
appleId: process.env.APPLE_ID,
appleIdPassword: process.env.APPLE_PASSWORD,
teamId: process.env.APPLE_TEAM_ID,
},
},
makers: [
{ name: "@electron-forge/maker-squirrel", config: {} },
{ name: "@electron-forge/maker-dmg", config: {} },
{ name: "@electron-forge/maker-deb", config: {} },
{ name: "@electron-forge/maker-rpm", config: {} },
],
publishers: [
{
name: "@electron-forge/publisher-github",
config: {
repository: { owner: "myorg", name: "my-app" },
prerelease: false,
},
},
],
plugins: [
{
name: "@electron-forge/plugin-vite",
config: {
build: [{ entry: "src/main.js", config: "vite.main.config.mjs" }],
renderer: [{ name: "main_window", config: "vite.renderer.config.mjs" }],
},
},
],
};
Auto-Update
// main.js
const { updateElectronApp } = require("update-electron-app");
updateElectronApp({
repo: "myorg/my-app",
updateInterval: "1 hour",
});
Publish to GitHub Releases → users get auto-updates.
Vite Plugin (Fast Builds)
Electron Forge supports Vite out of the box:
npm init electron-app@latest my-app -- --template=vite-typescript
Hot Module Replacement in your renderer process — instant feedback.
CI/CD Build Pipeline
# .github/workflows/build.yml
name: Build & Release
on:
push:
tags: ["v*"]
jobs:
build:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm ci
- run: npm run make
- run: npm run publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
One git tag → builds for macOS, Linux, Windows → publishes to GitHub Releases.
Why Electron Forge?
| Feature | Forge | electron-builder |
|---|---|---|
| Official | Yes | Community |
| Vite Support | Built-in | Plugin |
| Auto-Updates | Built-in | Separate |
| Code Signing | Integrated | Manual |
| Plugin System | Yes | Limited |
Need a custom desktop app or build pipeline automation?
📧 spinov001@gmail.com
🔧 My tools on Apify Store
What do you use for desktop apps? Share in the comments!
Top comments (0)