electron-updater package. This allows your application to automatically check for and install new versions, providing a seamless update experience for your users.
Auto-Updatable Targets
The following targets support auto-updates out of the box:- macOS: DMG
- Linux: AppImage, DEB, Pacman (beta), RPM
- Windows: NSIS
Squirrel.Windows is not supportedSimplified auto-update is supported on Windows with the default NSIS target, but not with Squirrel.Windows. You can easily migrate to NSIS.For macOS, the
zip target is required for Squirrel.Mac, otherwise latest-mac.yml cannot be created. The default target for macOS is dmg+zip, so no explicit configuration is needed.Why electron-updater?
Theelectron-updater package offers significant advantages over Electron’s built-in autoUpdater:
- Cross-platform support: Works on Linux, macOS, and Windows
- Code signature validation: Validates on both macOS and Windows
- Automated metadata: All required metadata files and artifacts are produced and published automatically
- Download progress: Supports download progress and staged rollouts on all platforms
- Multiple providers: GitHub Releases, Amazon S3, DigitalOcean Spaces, Keygen, and generic HTTP(s) servers
- Simple setup: Only 2 lines of code to make it work
Quick Setup Guide
Configure publish options
Configure the
publish options in your package.json or electron-builder.yml to specify where you want to host your release files.Build and verify
Build your application and verify that the build directory contains the metadata Look for files like
.yml files next to the built application:latest.yml, latest-mac.yml, or latest-linux.yml in your build output.Implementation Examples
Basic Setup with Logging
Custom Options with Direct Instantiation
If you need more control over the updater configuration (e.g., custom request headers for authorization):Handling Update Events
Debugging
You don’t need to listen to all events to understand what’s wrong. Just set alogger. electron-log is recommended:
Development Testing
To develop/test the update UI/UX without packaging the application:- Create a file named
dev-app-update.ymlin the root of your project - Match your
publishsetting from electron-builder config (in YAML format) - Force the updater to work in “dev” mode:
Staged Rollouts
Staged rollouts allow you to distribute the latest version to a subset of users, increasing the percentage over time (similar to Google Play rollouts). Edit yourlatest.yml / latest-mac.yml file manually:
Private GitHub Updates
You can use a private repository for updates by setting theGH_TOKEN environment variable on user machines and the private option in your configuration.
Events
TheautoUpdater object emits the following events:
error
Emitted when there is an error while updating.
Arguments: error (Error)
checking-for-update
Emitted when checking if an update has started.
update-available
Emitted when there is an available update. The update is downloaded automatically if autoDownload is true.
Arguments: info (UpdateInfo)
update-not-available
Emitted when there is no available update.
Arguments: info (UpdateInfo)
download-progress
Emitted on download progress.
Arguments: progress (ProgressInfo)
bytesPerSecond: Download speedpercent: Percentage completedtotal: Total bytestransferred: Bytes transferred
update-downloaded
Emitted when an update has been downloaded.
Arguments: info (UpdateInfo)
Compatibility
Generated metadata file formats change over time, but compatibility is preserved back to version 1. For new projects, setelectronUpdaterCompatibility to the current latest format version:
1.0.0: latest-mac.json2.15.0: path support2.16.0: files support
Platform-Specific Updaters
TheautoUpdater automatically selects the appropriate updater based on the platform:
main.ts:24-59