Packaging and Distribution
Why Package Your App?
Once you've built your Electron application, you'll want to distribute it to users. Packaging creates executable files that users can run without installing Node.js or development tools.
Distribute your app for Windows, macOS, and Linux from a single codebase.
Popular Packaging Tools
There are several tools available for packaging Electron applications:
- Use
electron-packager- Simple and straightforward packaging tool - Use
electron-builder- Advanced packaging with auto-update support and installers - Electron Forge - Complete toolchain for building and publishing
Using electron-packager
Electron Packager is a simple tool for packaging your application:
// Install electron-packager
npm install electron-packager --save-dev
// Package your application
npx electron-packager . MyApp --platform=win32,darwin,linux --arch=x64
This command creates distributable packages for Windows, macOS, and Linux.
Using electron-builder
Electron Builder provides more advanced features including auto-updates and installers:
// Install electron-builder
npm install electron-builder --save-dev
// Add build configuration to package.json
{
"build": {
"appId": "com.example.myapp",
"mac": {
"category": "public.app-category.productivity"
},
"win": {
"target": "nsis"
},
"linux": {
"target": "AppImage"
}
}
}
// Build your application
npm run build
Platform-Specific Considerations
- Windows - Create .exe installers with NSIS or Squirrel
- macOS - Generate .dmg files and handle code signing
- Linux - Build .deb, .rpm, or AppImage formats
Code Signing
For production apps, you should sign your application:
- Windows: Use a code signing certificate
- macOS: Use an Apple Developer certificate
- Linux: Sign with GPG keys (optional)
Code signing helps users trust your application and is required for some distribution channels.
Distribution Channels
Once packaged, you can distribute your app through various channels:
- Direct download from your website
- Mac App Store (requires Apple Developer account)
- Microsoft Store (requires Microsoft Developer account)
- Snap Store or Flatpak for Linux
- GitHub Releases