Lesson 13 of 28
javascriptAuto‑Updates with electron‑updater
13 mins
Course progress46%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 13 of 28
javascript13 mins
Keep these ideas in mind as you work through the lesson.
electron‑updater (part of electron‑builder) abstracts away the platform‑specific update mechanisms (Squirrel on Windows, NSIS, macOS app‑store, etc.).
npm install electron-updater
main.jsconst { autoUpdater } = require('electron-updater');
autoUpdater.checkForUpdatesAndNotify();
autoUpdater.on('update-available', info => {
console.log('Update available', info.version);
});
autoUpdater.on('update-downloaded', info => {
const choice = dialog.showMessageBoxSync({
type: 'question',
buttons: ['Later', 'Install now'],
defaultId: 1,
message: `Version ${info.version} downloaded. Install now?`
});
if (choice === 1) autoUpdater.quitAndInstall();
});
*.exe, *.dmg, *.AppImage files.publish field in package.json:"build": {
"publish": [{ "provider": "github", "owner": "myuser", "repo": "my‑app" }]
}
Now each new release is automatically detected by autoUpdater.