Skip to main content
Overlayed provides two update systems: App updates (the Electron app) and Site updates (your frontend).

App Updates

The overlayed.updater module provides methods to check for updates, switch channels, and install updates.

Checking for Updates

const result = await overlay.updater.checkForUpdates();

Listening to Update Events

overlay.updater.on("updateAvailable", ({ info }) => {
	overlay.log.info(`Update available: ${info.version}`);
});

overlay.updater.on("updateDownloaded", ({ event }) => {
	overlay.log.info("Update downloaded, ready to install");
});

overlay.updater.on("error", ({ error, message }) => {
	overlay.log.error("Update error:", message);
});

Installing Updates

After an update is downloaded, you can install it:
function handleUpdate() {
	const [canUpdate, reason] = overlay.updater.canUpdate();

	if (canUpdate) {
		overlay.updater.quitAndInstall(true, true);
	} else {
		overlay.log.error(`Cannot update: ${reason}`);
	}
}

overlay.updater.on("updateDownloaded", () => handleUpdate());
Alternatively, you can wait for the checkForUpdates promise to resolve:
const result = await overlay.updater.checkForUpdates();
if (result && result.isUpdateAvailable) {
	handleUpdate();
}
quitAndInstall will throw an error if canUpdate() returns false. This happens when the user is currently in a game.

Private Channels

For private update channels, you must provide an access token fetcher:
overlay.updater.setAccessTokenFetcher((channel) => {
	// Fetch a token for the given channel from your auth system
	return getTokenForChannel(channel);
});
Listen for token invalidation when they lose access and move them to the public channel:
overlay.updater.on("authTokenInvalid", async () => {
	await overlay.updater.checkForUpdates();
	overlay.updater.quitAndInstall(true, true);
});
See Private Channels for full server implementation examples.

Switching Channels

To switch update channels (e.g., from stable to beta):
await overlay.updater.switchChannel("beta");
await overlay.updater.checkForUpdates();

Site Updates

The overlayed.updater.site module handles Site updates separately from App updates.

Automatic Updates (Default)

By default, Site updates are applied automatically. When you deploy a new Site version, users will receive it on the next call of BrowserWindow#loadURL.

Manual Updates

To control when Site updates are applied, enable manual updates:
const overlay = overlayed({
	site: {
		manualUpdates: true,
	},
});
Then listen for new versions and prompt users:
overlay.updater.site.on("siteUpdateReady", ({ version }) => {
	showUpdatePrompt(version);
});

function onUserClicksUpdate() {
	overlay.updater.site.allowSiteUpdateOnNextLoad();
	// Reload all windows to apply the update
	allWindows.forEach((window) => window.webContents.reload());
}

Application Info

The overlayed.application module provides information about the current release:
const channel = overlay.application.getChannel();
const version = overlay.application.getVersion();
const releaseId = overlay.application.getReleaseId(); // null during development
We recommend showing the channel and version in your UI to help users give better feedback and bug reports.

Update Events Reference

EventDescription
checkingForUpdatesStarted checking for updates
updateAvailableAn update is available
updateNotAvailableNo update available
downloadProgressDownload progress update
updateDownloadedUpdate has finished downloading
updateCancelledUpdate was cancelled
errorAn error occurred
authTokenInvalidAccess token is invalid or expired