Docs

Protocols (window.Electron.protocols)

Custom-URL-scheme registration and app-wide external link handoff. Source: src/main/protocol.ts, channel prefix protocol:*. Always on, no config needed — reads app.deepLinkingScheme and app.appLauncherSchemes from App configuration.

This is a different, narrower thing than Managed windows' own openExternal — that one is about a popup/navigation escaping a specific managed external window and uses app.externalWindowAllowedSchemes. This module's openExternal is for links the whole app wants to hand off to the OS (e.g. a "visit our website" button), and always allows http:/https:/mailto: plus the app's own configured deep-link scheme(s).

Methods

Method Returns Notes
getConfiguredSchemes() Promise<string[]> The deduplicated union of app.deepLinkingScheme and app.appLauncherSchemes.
isProtocolHandled(scheme: string) Promise<boolean> Whether Electron's own protocol module has a handler registered for scheme.
isDefaultProtocolClient(scheme: string) Promise<boolean> Whether this app is the OS's default handler for scheme.
setAsDefaultProtocolClient(scheme: string) Promise<boolean> Throws NOT_CONFIGURED if scheme isn't one of getConfiguredSchemes() — you can't register the app for an arbitrary scheme at runtime, only for the ones declared in electron.config.ts.
removeAsDefaultProtocolClient(scheme: string) Promise<boolean>
openExternal(url: string) Promise<void> Throws VALIDATION for an unparseable URL or a scheme outside http:/https:/mailto:/configured deep-link schemes.

Every scheme argument is normalized (trimmed, lowercased, :///: suffix stripped) and validated against /^[a-z][a-z0-9+.-]*$/i — an invalid scheme throws VALIDATION before any Electron API is touched.

Example

const schemes = await window.Electron.protocols.getConfiguredSchemes(); // e.g. ['myapp']
if (!(await window.Electron.protocols.isDefaultProtocolClient('myapp'))) {
  await window.Electron.protocols.setAsDefaultProtocolClient('myapp');
}

await window.Electron.protocols.openExternal('https://example.com');

See Deep linking for handling the incoming myapp://... URL once the OS routes it back to your app.

.safe

Fully mirrored — window.Electron.safe.protocols.* resolves { ok: true, data } / { ok: false, error } instead of throwing.

Last updated on July 18, 2026