electron/docs/tutorial/updates.md
2017-08-12 01:24:56 +02:00

2.3 KiB
Raw Blame History

Updating Applications

There are several ways to update an Electron application. The easiest and officially supported one is taking advantage of the built-in Squirrel framework and the autoUpdater module that comes with it.

Deploying an Update Server

To get started, you firstly need to deploy an update server (that's where the autoUpdater module will download new updates from).

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

Implementing Updates into Your App

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 Hazel).

Important: Please ensure that the code below will only be executed in production - you can use electron-is-dev to check for the environment).

const { app, autoUpdater } = require('electron')

Next, put together the URL of the update server:

const server = <your-deployment-url>
const feed = `${server}/update/${process.platform}/${app.getVersion()}`

As the final step, tell autoUpdater where to ask for updates:

autoUpdater.setFeedURL(feed)

That's all. Once built, your application will receive an update for each new GitHub Release that you create.

Further Steps

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 events).

Also make sure that potential errors are being handled.