Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Electron Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-electron-knowledge-patch-nevaberry-plugins)
---
name: electron-knowledge-patch
description: Electron
version: "45.5.0"
license: MIT
metadata:
author: Nevaberry
---
# Electron compatibility
Use this skill when upgrading an Electron app or changing its preloads,
permissions, protocols, windows, native integrations, or packaging.
Load the relevant topic reference for complete guidance and examples.
## Reference index
| Reference | Topics |
| --- | --- |
| [Upgrades and runtime](references/upgrades-and-runtime.md) | Runtime dependencies, platform support, installation, native add-ons, packaging, ASAR, updates |
| [Sessions, protocols, and extensions](references/sessions-protocols-and-extensions.md) | Preloads, service workers, extensions, request filters, protocols, storage, cookies, devices |
| [Processes, security, and diagnostics](references/processes-security-and-diagnostics.md) | Permissions, sandboxing, frames, authentication, safe storage, utility processes, crashes, tracing |
| [Windows, menus, and platform integration](references/windows-menus-and-platform-integration.md) | Window state, popups, input, menus, dialogs, notifications, accessibility, desktop integration |
| [Graphics, media, and NativeImage](references/graphics-media-and-native-image.md) | Clipboard migration, image color, shared textures, offscreen rendering, capture, printing, PDFs, CSS |
## Breaking changes and deprecations
### Sandboxed and embedded-extension preloads
Electron 45 removes the `events`, `timers`, and `url` modules and the `Buffer`,
`setImmediate`, and `clearImmediate` globals from sandboxed preloads.
Bundle polyfills for the APIs the preload uses.
In Electron 45, a `chrome-extension://` document gets window and session
preloads when it is a top-level frame or runs inside the DevTools frontend.
Extension frames embedded in ordinary pages follow `nodeIntegrationInSubFrames`.
### Clipboard access and asynchronous formats
Electron 44 removes direct renderer access to `clipboard`, including in
unsandboxed renderers. Use `navigator.clipboard` for standard renderer operations.
Electron 40 deprecated direct renderer access and advised moving Electron
clipboard calls into a preload, exposing operations through `contextBridge`.
In Electron 44, await `clipboard.readText()`, `clipboard.writeText()`, and
`clipboard.has(mimeType)`. Write related formats atomically with `clipboard.write()`.
Replace `availableFormats()` with `clipboard.read()`, inspect each item's `types`,
and use `getType(mimeType)` to read a format, usually as a `Blob`.
Use `clipboard.selection` on Linux in place of the removed clipboard type argument.
See the graphics reference for format, bookmark, and native-file migrations.
### ASAR descriptors and integrity
In Electron 45, `fs.open()`, `fs.openSync()`, and `fs.promises.open()` on a packed
file return an archive-entry descriptor usable by Node's `fs` methods.
Raw descriptor consumers, including native add-ons and child-process stdio,
fail with `EBADF` and need a file outside the archive. Write-mode opens and
`fs.fchmod()`, `fs.fchown()`, and `fs.futimes()` fail with `EACCES`.
ASAR integrity validation is stable in Electron 39. When enabled, it checks
`app.asar` against its build-time hash and terminates the app if the hash is
missing or mismatched. For Electron 41 macOS apps using ASAR integrity, embed
the metadata digest with `@electron/asar` 4.1.0 or later, then re-sign the app:
```bash
asar integrity-digest on /path/to/YourApp.app
```
### Capture permissions and frame attribution
In Electron 45, screen, window, and tab capture requests arrive at
`session.setPermissionRequestHandler()` as `display-capture`. Update handlers
that only allow `media` to handle `display-capture` for permitted screen sharing.
In Electron 42.11.3, 43.7.0, and 44.3.0, capturing WebContents IDs with
`getUserMedia()` requires `chromeMediaSource: 'tab'`. Use the target's
`webContents.getMediaSourceId()`, or grant it through `session.setDisplayMediaRequestHandler()`.
Those releases also require user activation in the calling frame for
`document.execCommand('paste')`.
### Safe storage, tracing, and storage access
Electron 45 deprecates `safeStorage.isEncryptionAvailable()`, `encryptString()`,
and `decryptString()` ahead of removal in 46. Use `isAsyncEncryptionAvailable()`,
`encryptStringAsync()`, and `decryptStringAsync()` from the same module.
Use `decryptStringAsync()` for existing ciphertext too.
Electron 45 removes `contentTracing.enableHeapProfiling()`. Pass
`nativeHeapProfiling` to `contentTracing.startRecording()` for native heap
profiling during the trace, and read the output as Perfetto protobuf.
Electron 45 disables `document.requestStorageAccessFor()` by default.
To restore it temporarily, set `webPreferences.enableBlinkFeatures` to
`'RequestStorageAccessFor'`.
### Popup sandbox boundaries and worker integration
In Electron 45, a `window.open()` child with a different sandbox setting runs
in its own renderer process and loses its opener relationship. To preserve
that relationship when the opener is deliberately unsandboxed, set
`overrideBrowserWindowOptions.webPreferences.sandbox: false` in its
`setWindowOpenHandler()` result.
In Electron 42.11.3, 43.7.0, and 44.3.0, `nodeIntegrationInWorker` applies only
if the creating frame has Node.js integration. Subframes that need to create
Node-enabled workers also require `nodeIntegrationInSubFrames`.
### Permission callbacks and frame lifetime
Since Electron 13, the first argument to `session.setPermissionCheckHandler()`
can be `null`. Use `requestingOrigin` and, when needed, the details object's
`embeddingOrigin` or `securityOrigin` for permission decisions.
Since Electron 33, read frame-valued properties such as `event.senderFrame`
synchronously at the start of the listener; after an `await`, the property can
return `null` if the sender navigated cross-origin.
### Binary installation and platform changes
In Electron 42, the npm package downloads its binary into `node_modules` when
its CLI first runs. `ELECTRON_SKIP_BINARY_DOWNLOAD` is removed; installation
supports `--ignore-scripts`. To fetch the binary during setup:
```sh
npm install --save-dev --ignore-scripts electron
npx install-electron
```
Set `ELECTRON_INSTALL_PLATFORM` and `ELECTRON_INSTALL_ARCH` for a different target.
Electron 44 requires macOS 13 or later. Electron 43 is the last series with
prebuilt Windows x86 and Linux ARM binaries; support ends in January 2027.
Electron 38 defaults to `--ozone-platform=auto`, selecting native Wayland in a
Wayland session. Replace the removed `ELECTRON_OZONE_PLATFORM_HINT` with
`--ozone-platform=x11` if the app needs X11 compatibility through Xwayland.
### API replacements and dialog behavior
- Replace deprecated `image.getBitmap()` with `image.toBitmap()`; both allocate a copy.
- Move extension methods and events from `session` to `session.extensions`.
- Electron 42 removes `quotas` from `session.clearStorageData()`.
- Electron 43 removes `showHiddenFiles` from Linux dialogs.
- Electron 43 file dialogs stop restoring the last-used directory without
`defaultPath`; save the directory after selection and pass it on the next call.
- Replace `--host-rules` with `--host-resolver-rules`.
- Read app-specific arguments from `process.argv` to preserve case;
`app.commandLine` lowercases switches and arguments, and added switches stay
in the main process.
## Common feature patterns
### Session preload registration and filters
Replace `setPreloads` and `getPreloads` with `registerPreloadScript`,
`unregisterPreloadScript`, and `getPreloadScripts` to manage scripts individually.
For Electron 44.10.0 and 45.1.0, registration supports `matches`, `excludeMatches`,
`includeGlobs`, `excludeGlobs`, and `matchOriginAsFallback`.
```js
ses.registerPreloadScript({
type: 'frame',
filePath: preloadPath,
matches: ['https://app.example/*'],
excludeMatches: ['https://app.example/admin/*'],
});
```
Use `type: 'service-worker'` for service-worker preloads, including Manifest V3
extension workers. Pair preload `ipcRenderer` with the worker's `ServiceWorkerMain.ipc`.
Use `session.serviceWorkers.getInfoFromVersionID(versionId)` for metadata and
`getWorkerFromVersionID(versionId)` for the worker instance.
### Network filters and custom protocols
An empty `WebRequestFilter.urls` array no longer selects every URL.
Use `{ urls: ['<all_urls>'] }` for all URLs, and `excludeUrls` to skip matches.
Set `bypassCustomProtocolHandlers: true` in `net.request` options to bypass
custom protocol handlers for a request.
Electron 44.6.0 and 45.0.0 add experimental `protocol.registerSource()` to serve
custom schemes from directories. In 44.10.0 and 45.1.0, these schemes follow the
same fetch rules as `protocol.handle()` schemes.
### Offscreen rendering and image color
In Electron 42, offscreen rendering defaults to device scale factor `1.0`,
independent of the primary display. Set `webPreferences.offscreen.deviceScaleFactor`
to control rendered pixel size. In 43.7.1 and 44.4.0, `webContents.capturePage()`
uses that offscreen scale independently of the display scale.
Electron 43 normalizes profiled source images to sRGB in `nativeImage`.
Pass the original profile through `colorSpace` to `NativeImage.toBitmap()` to
preserve previous pixel values. See the graphics reference for the Display P3 example.
### Frames, notifications, and extension storage
Replace `webFrame.routingId` and `webFrame.findFrameByRoutingId(routingId)` with
`webFrame.frameToken` and `webFrame.findFrameByToken(frameToken)`. In the main
process, use `webFrameMain.fromFrameToken(processId, frameToken)`.
In Electron 42, macOS notifications require a code-signed app; unsigned-app
notifications emit `failed`. On Windows, `Notification.handleActivation(callback)`
receives clicks, replies, and action-button activations, including app launches.
Electron 45.2.0 provides `chrome.storage.sync` as a separate, device-local area
using Chrome's sync storage quotas. Electron 45.3.0 adds read-only
`chrome.storage.managed`; read with `await chrome.storage.managed.get(null)`.
Writes to managed storage reject.