Enable apps to automatically update themselves.
autoUpdater module provides an interface for the Squirrel framework.
You can quickly launch a multi-platform release server for distributing your application by using one of these projects:
autoUpdater provides a uniform API for different platforms, there are still some subtle differences on each platform.
On macOS, the
autoUpdater module is built upon Squirrel.Mac, meaning you don’t need any special setup to make it work. For server-side requirements, you can read Server Support. Note that App Transport Security (ATS) applies to all requests made as part of the update process. Apps that need to disable ATS can add the
NSAllowsArbitraryLoads key to their app’s plist.
Note: Your application must be signed for automatic updates on macOS. This is a requirement of
On Windows, you have to install your app into a user’s machine before you can use the
autoUpdater, so it is recommended that you use the electron-winstaller, electron-builder or the grunt-electron-installer package to generate a Windows installer.
When using electron-winstaller or electron-builder make sure you do not try to update your app the first time it runs (Also see this issue for more info). It’s also recommended to use electron-squirrel-startup to get desktop shortcuts for your app.
The installer generated with Squirrel will create a shortcut icon with an Application User Model ID in the format of
com.squirrel.PACKAGE_ID.YOUR_EXE_WITHOUT_DOT_EXE, examples are
com.squirrel.code.Code. You have to use the same ID for your app with
app.setAppUserModelId API, otherwise Windows will not be able to pin your app properly in task bar.
The server-side setup is also different from macOS. You can read the documents of Squirrel.Windows to get more details.
There is no built-in support for auto-updater on Linux, so it is recommended to use the distribution’s package manager to update your app.
autoUpdater object emits the following events:
Emitted when there is an error while updating.
Emitted when checking if an update has started.
Emitted when there is an available update. The update is downloaded automatically.
Emitted when there is no available update.
Emitted when an update has been downloaded.
On Windows only
releaseName is available.
autoUpdater object has the following methods:
requestHeadersObject macOS (optional) - HTTP request headers.
url and initialize the auto updater.
String - The current update feed URL.
Asks the server whether there is an update. You must call
setFeedURL before using this API.
Restarts the app and installs the update after it has been downloaded. It should only be called after
update-downloaded has been emitted.
autoUpdater.quitAndInstall() will close all application windows first and only emit
before-quit event on
app after that. This is different from the normal quit event sequence.
© 2013–2017 GitHub Inc.
Licensed under the MIT license.