Updating Applications

    The Electron team maintains update.electronjs.org, a free and open-source webservice that Electron apps can use to self-update. The service is designed for Electron apps that meet the following criteria:

    • App runs on macOS or Windows
    • App has a public GitHub repository
    • Builds are published to GitHub Releases
    • Builds are code-signed

    The easiest way to use this service is by installing , a Node.js module preconfigured for use with update.electronjs.org.

    Install the module:

    Invoke the updater from your app’s main process file:

      If you need to customize your configuration, you can pass options to update-electron-app or .

      If you’re developing a private Electron application, or if you’re not publishing releases to GitHub Releases, it may be necessary to run your own update server.

      Depending on your needs, you can choose from one of these:

      • Hazel – Update server for private or open-source apps which can be deployed for free on . It pulls from GitHub Releases and leverages the power of GitHub’s CDN.
      • – Also uses GitHub Releases, but caches app updates on disk and supports private repositories.
      • – Provides a dashboard for handling releases and does not require releases to originate on GitHub.
      • Nucleus – A complete update server for Electron apps maintained by Atlassian. Supports multiple applications and channels; uses a static file store to minify server cost.

      Once you’ve deployed your update server, continue with importing the required modules in your code. The following code might vary for different server software, but it works like described when using .

      Next, construct the URL of the update server and tell autoUpdater about it:

      1. const server = 'https://your-deployment-url.com'
      2. const url = `${server}/update/${process.platform}/${app.getVersion()}`
      3. autoUpdater.setFeedURL({ url })

      As the final step, check for updates. The example below will check every minute:

      Once your application is , it will receive an update for each new GitHub Release that you publish.

      Now that you’ve configured the basic update mechanism for your application, you need to ensure that the user will get notified when there’s an update. This can be achieved using the autoUpdater API :

      1. type: 'info',
      2. buttons: ['Restart', 'Later'],
      3. title: 'Application Update',
      4. message: process.platform === 'win32' ? releaseNotes : releaseName,
      5. detail: 'A new version has been downloaded. Restart the application to apply the updates.'
      6. dialog.showMessageBox(dialogOpts).then((returnValue) => {
      7. if (returnValue.response === 0) autoUpdater.quitAndInstall()
      8. })

      Because the requests made by Auto Update aren’t under your direct control, you may find situations that are difficult to handle (such as if the update server is behind authentication). The field does support files, which means that with some effort, you can sidestep the server-communication aspect of the process. Here’s an example of how this could work.