Information on this page has been adapted from the official @electron/fuses integration and Electron tutorial.
What are Fuses?
For a subset of Electron functionality, it makes sense to disable certain features for an entire application. For example, 99% of apps don’t make use ofELECTRON_RUN_AS_NODE, and these applications want to ship a binary that is incapable of using that feature.
Fuses are “magic bits” in the Electron binary that can be flipped when packaging your Electron app to enable or disable certain features and restrictions. Because they are flipped at package time before you code sign your app, the operating system becomes responsible for ensuring those bits aren’t flipped back via OS-level code signing validation (Gatekeeper / App Locker).
Configuration
electron-builder leverages the official@electron/fuses module to make flipping fuses easy. You can configure fuses using the electronFuses configuration property.
Using electronFuses Configuration
The true/false values below are just examples. Customize your configuration to match your own requirements.
Using afterPack Hook
You can also configure fuses in theafterPack hook for more advanced customization. electron-builder exposes a convenience method in the PlatformPackager that accepts an AfterPackContext and a FuseConfig object.
This method allows you to:
- Provide custom FuseConfig objects
- Use
strictlyRequireAllFusesto monitor your fuses and stay up-to-date as new fuses are released - Force override the version of @electron/fuses in electron-builder
afterPack.ts
Available Fuses
Disables the
ELECTRON_RUN_AS_NODE environment variable, which allows running the Electron app as a Node.js script.Enables encryption for cookies stored by Electron.
Controls whether the
NODE_OPTIONS environment variable is respected.Controls whether Node.js CLI inspect arguments (like
--inspect) are enabled.Enables validation of the ASAR archive integrity to prevent tampering.
Forces the app to load only from the ASAR archive, ignoring unpacked files.
Loads a browser-process-specific V8 snapshot for faster startup.
Controls whether the file protocol has extra privileges.
Validating Fuses
You can validate that fuses have been flipped correctly or check the fuse status of any Electron app using the fuses CLI:Next Steps
Configuration Reference
View all configuration options including electronFuses
Build Hooks
Learn more about afterPack and other build hooks