Docs

System & window

Always-on window control, app info, badge count, progress bar, and native file drag-out for the main window — no config needed. Source: src/main/system.ts, channel prefix system:*. These are flat, top-level methods directly on window.Electron (not under a namespace). For a second/secondary window, see Managed windows instead.

Window control

Method Returns Notes
quit() Promise<void> Quits the app.
minimize() Promise<void>
maximize() Promise<void>
unmaximize() Promise<void>
toggleMaximize() Promise<void>
isMaximized() Promise<boolean>
setFullscreen(flag: boolean) Promise<void>
isFullscreen() Promise<boolean>
focus() Promise<void> Brings the window to the front.
reload() Promise<void> Reloads the renderer.
openDevTools() Promise<void>
closeDevTools() Promise<void>

App info

Method Returns Notes
getAppVersion() Promise<string> From package.json.
getPlatform() Promise<NodeJS.Platform> 'darwin' | 'win32' | 'linux' | ... — Node's process.platform as seen by the main process.
getLanguageCode() Promise<string> Primary language subtag of app.getLocale(), e.g. 'en' for 'en-US'.
getDeviceId() Promise<string> Persistent per-install UUID, created on first call and stored under userData.
isFocused() Promise<boolean> Whether the sender window currently has OS focus.
onAppStateChange(callback: (data: { isActive: boolean }) => void) () => void (unsubscribe) Fires whenever the app as a whole gains or loses OS focus (any window focused vs none) — the desktop analogue of a mobile app's foreground/background state. Not part of .safe (event subscription, never throws).

Badge count

Method Returns Notes
setBadgeCount(count: number) Promise<boolean> Sets the dock/taskbar badge. Resolves false on platforms that don't support it instead of failing.
getBadgeCount() Promise<number>

Progress bar

setProgressBar(progress: number, options?: { mode?: 'none' | 'normal' | 'indeterminate' | 'error' | 'paused' }): Promise<void>

Shows progress on the taskbar icon (Windows/Linux) or Dock icon (macOS). progress is 0–1; values >= 1 clear the bar, negative values remove it entirely. options.mode is Windows-only (ignored on macOS/Linux, which only show a plain progress bar).

await window.Electron.setProgressBar(0.42);
await window.Electron.setProgressBar(-1); // remove it

Native file drag-out

startFileDrag(item: { file: string; files?: string[]; icon: string }): Promise<void>

Starts an OS-level drag of a file (or files, via files which overrides file) out of the window — e.g. letting the user drag an exported PDF onto their desktop or another app. Must be called from the renderer's own dragstart handler — calling it at any other time has no effect. icon is required (and must be non-empty) on macOS.

someElement.addEventListener('dragstart', () => {
  void window.Electron.startFileDrag({ file: '/path/to/export.pdf', icon: '/path/to/icon.png' });
});

.safe

Every method above except onAppStateChange (an event subscription, never throws) is fully mirrored at window.Electron.safe.* — same flat shape, e.g. window.Electron.safe.getAppVersion() resolves { ok: true, data: '1.2.3' }. See API reference: .safe.

Last updated on July 18, 2026