Docs

API reference

Full method-by-method reference for window.Electron, grouped by module — one page per src/main/*.ts file, matching how the source itself is organized (see Architecture). Read this page first: it explains the throwing vs .safe pattern every single method in this API follows, then indexes every module.

If you just want task-oriented examples and the React hooks, see Usage instead — this section is for looking up an exact method signature once you already know what you need.

How every call is built

electron/preload.ts calls createElectronBridge() (src/preload/index.ts), which builds one raw object first — every wrapped method on it resolves to an IpcResult<T> ({ ok: true, data } or { ok: false, error }) and never throws. That raw object is exposed as-is at window.Electron.safe.*. The default, throwing window.Electron.* surface is then derived from that same raw object by two small helpers in src/preload/ipc.ts:

// src/preload/ipc.ts (verbatim)
export function unwrap<T>(promise: Promise<IpcResult<T>>): Promise<T> {
  return promise.then((result) => {
    if (!result.ok) throw new IpcError(result.error.code, result.error.message);
    return result.data;
  });
}

export function unwrapAll<T extends object>(ns: T): UnwrapIpcResult<T> {
  /* wraps every method on ns with unwrap() */
}

export function unwrapSome<T extends object>(ns: T, keys: readonly (keyof T)[]): UnwrapIpcResult<T> {
  /* wraps only the named methods; everything else on ns is copied through as-is */
}

No method body is ever hand-duplicated between the two flavors — window.Electron.clipboard.readText() and window.Electron.safe.clipboard.readText() call the exact same main-process handler over the exact same IPC channel (clipboard:readText). The only difference is what happens to a { ok: false } result on the way back to your code:

window.Electron.<ns>.<method>() window.Electron.safe.<ns>.<method>()
Success resolves with the data directly resolves { ok: true, data }
Failure throws an IpcError (.code, .message) resolves { ok: false, error: { code, message } } — never throws

Use the throwing default when a failure is exceptional and you're fine with a try/catch (or letting it bubble to an error boundary / onElectronError). Reach for .safe when a failure is a normal branch you want to check inline — the two most common cases are NOT_CONFIGURED (a feature you haven't turned on yet) and UNSUPPORTED_OS (a platform-gated method):

// Throwing default — try/catch
import { isIpcError } from '@devioarts/electron';

try {
  await window.Electron.autoLaunch.setEnabled(true);
} catch (e) {
  if (isIpcError(e) && e.code === 'UNSUPPORTED_OS') return; // expected on Linux
  throw e;
}

// .safe mirror — no try/catch, just check result.ok
const result = await window.Electron.safe.autoLaunch.setEnabled(true);
if (!result.ok) {
  if (result.error.code === 'UNSUPPORTED_OS') return; // expected on Linux
  console.error(result.error.message);
}

Both forms are always available side by side — .safe is not a config flag or a different bridge, it's the same window.Electron object with a safe property hanging off it.

Not every method has a .safe counterpart

A handful of methods are plain event subscriptions or fire-and-forget calls that can never fail in a way worth reporting — they have no IpcResult, and therefore no .safe variant, because there is nothing to unwrap either way. Calling them is inherently "safe": onDeepLink, onShortcut, onMenuAction, onPowerMonitorEvent, onScreenEvent, onElectronError, onAppStateChange, and updater.quitAndInstall(). These exist only on the default window.Electron.* surface (updater.on() is the one exception — see the Updater page — it's also mirrored onto .safe.updater.on() as the literal same function, since it never throws either).

Per-namespace .safe coverage

Some namespaces are fully wrapped (every method has a .safe twin); some are partially wrapped (the namespace mixes request/response methods with an on() event subscriber — only the request/response methods have a .safe twin, since subscribers never throw to begin with):

Namespace .safe coverage Methods without a .safe twin
Flat top-level (window control, app info, badge, progress bar, file drag, power monitor idle state, power save blocker, screen queries, registerShortcut/unregisterShortcut, showContextMenu) Full —
updater Partial quitAndInstall() (fire-and-forget), on() (subscription, but mirrored onto .safe unchanged)
dialogs Full —
secureStorage Full —
protocols Full —
session Full —
downloads Partial on()
print Full —
desktopCapture Full —
autoLaunch Full —
nativeTheme Partial onUpdated()
windows Full —
externalCommands Partial onOutput(), onExit()
clipboard Full —
notifications Partial on()
systemPreferences Full —
crashReporter Full —
utilityProcess Partial onMessage(), onExit()
Filesystem (plugin) Full —
Preferences (plugin) Full —
Network (plugin) Partial on()
FileViewer (plugin) Full —
PrivacyScreen (plugin) Full —
Deep link / shortcuts events / menu actions / power monitor events / screen events / app state / errors (onDeepLink, onShortcut, onMenuAction, onPowerMonitorEvent, onScreenEvent, onAppStateChange, onElectronError) None — pure event subscriptions, not part of .safe at all all of them

Error codes

Every IpcError (thrown) or IpcResult.error (from .safe) carries a machine-readable code: IpcErrorCode:

Code Meaning
VALIDATION The call's arguments failed a check (bad shape, disallowed value, argument not in an allowlist).
NOT_CONFIGURED The feature exists on the bridge but is off — the matching electron.config.ts key isn't enabled, or the alias/task isn't declared.
RUNTIME The underlying operation failed at run time (process spawn failed, file operation errored, ...).
UNSUPPORTED_OS The method is gated to specific platforms and the current OS isn't one of them (e.g. autoLaunch on Linux).
FORBIDDEN The IPC sender-trust check rejected the calling frame. Should not happen from the app's own main window under normal operation — see Architecture: IPC trust model.
UNKNOWN An unclassified failure, typically an unexpected exception caught by trustedIpcHandleSafe()'s catch-all.

Modules

Page Bridge surface Channel prefix Source
System & window Flat top-level: quit, minimize, ..., getAppVersion, getDeviceId, setBadgeCount, setProgressBar, startFileDrag, onAppStateChange system:* src/main/system.ts
Managed windows windows.* windows:* src/main/windows.ts
Updater updater.* updater:* src/main/updater.ts
Dialogs dialogs.* dialogs:* src/main/dialogs.ts
Secure storage secureStorage.* secureStorage:* src/main/secure-storage.ts
Protocols protocols.* protocol:* src/main/protocol.ts
Session session.* session:* src/main/session.ts
Downloads downloads.* downloads:* src/main/downloads.ts
Print print.* print:* src/main/print.ts
Desktop capture desktopCapture.* desktopCapture:* src/main/desktop-capture.ts
Auto launch autoLaunch.* autoLaunch:* src/main/auto-launch.ts
Native theme nativeTheme.* nativeTheme:* src/main/native-theme.ts
External commands externalCommands.* externalCommands:* src/main/external-commands.ts
Clipboard clipboard.* clipboard:* src/main/clipboard.ts
Notifications notifications.* notifications:* src/main/notifications.ts
System preferences systemPreferences.* systemPreferences:* src/main/system-preferences.ts
Crash reporter crashReporter.* crashReporter:* src/main/crash-reporter.ts
Utility process utilityProcess.* utilityProcess:* src/main/utility-process.ts
Power flat: getPowerMonitorIdleState, ..., onPowerMonitorEvent powerMonitor:*, powerSaveBlocker:* src/main/power-monitor.ts, src/main/power-save-blocker.ts
Screen flat: getAllDisplays, ..., onScreenEvent screen:* src/main/screen.ts
Shortcuts flat: registerShortcut, unregisterShortcut, onShortcut shortcuts:* src/main/shortcuts.ts
Menu flat: showContextMenu, onMenuAction menu:* src/main/menu.ts
Deep linking flat: onDeepLink (native URL scheme, not IPC) src/main/deep-link.ts
Errors flat: onElectronError electronError src/main/process-guardian.ts
Plugins: Built-in plugins Filesystem.*, Preferences.*, Network.*, FileViewer.*, PrivacyScreen.* plugin:<Name>:* src/plugins/*

Next: Usage for the React hooks and extending the bridge, or Configuration for what to set in electron.config.ts to unlock the opt-in modules above.

Last updated on July 18, 2026