app.updater checks for, downloads, and applies updates to compiled binaries.
const update = await app.updater.check({
currentVersion: app.info().version,
source: { type: "github", repo: "owner/repo", asset: process.platform === "win32" ? /\.exe$/ : /linux/ },
});
if (update.hasUpdate) {
console.log(`update available: ${update.version}`);
console.log(update.notes);
}source can be:
{ type: "github", repo: "owner/repo", prerelease?, asset }- checks the latest (or latest pre-release, ifprerelease: true) GitHub release.assetselects which release asset to use: aRegExp, a string (substring match), or a function(asset) => boolean.{ type: "manifest", url: "https://example.com/update.json" }- fetches a JSON manifest from a URL.{ type: "file", path: "./update.json" }- reads a local JSON manifest.
Manifest/file sources look like:
{ "version": "1.2.3", "url": "https://example.com/downloads/app-linux", "notes": "Bug fixes" }url may be http(s)://, a local filesystem path, or file://.
The result is { version, url, notes, currentVersion, hasUpdate }, where
hasUpdate is true if version is newer than currentVersion.
const file = await app.updater.download(update, "./update-download");
// file: path to the downloaded binaryDownloads update.url to dir (created if needed), reporting progress is not
built in - call this when you're ready to fetch the new binary.
app.updater.apply(file);Replaces the currently running binary with file and restarts the app.
Compiled builds only - this is a no-op (or throws) when run via bun run,
since there's no standalone binary to replace.
const update = await app.updater.check({ currentVersion: app.info().version, source: { /* ... */ } });
if (update.hasUpdate) {
const ok = await app.dialog.confirm({
title: "Update available",
message: `Version ${update.version} is available. Update now?`,
});
if (ok) {
const file = await app.updater.download(update, app.paths.userCache());
app.updater.apply(file);
}
}