Electron is an open-source framework developed by GitHub for building cross-platform desktop applications using web technologies like JavaScript, HTML, and CSS. It embeds Chromium and Node.js into a single runtime, allowing developers to create applications that run on Windows, macOS, and Linux from a single codebase. The current stable version is 41.2.1, with frequent patch and minor updates and a steady stream of beta releases (currently v42.0.0-beta.4) indicating an active and rapid development cycle. Key differentiators include its ability to leverage existing web development skills for desktop app creation, a large ecosystem of tools and libraries, and strong community support, making it a popular choice for apps requiring native system access and rich UI capabilities.
npm install electronVerified import paths — ran on the pinned version, not inferred.
This quickstart initializes an Electron application, creates a main window, loads an HTML file, and sets up basic lifecycle events. It emphasizes best practices for `webPreferences` like `nodeIntegration: false` and `contextIsolation: true` for enhanced security.
Review the official Electron release notes and migration guides for your target major version. Pay close attention to changes in `webPreferences` and security defaults.
Explicitly set `nodeIntegration: false` and `contextIsolation: true` in your `BrowserWindow`'s `webPreferences` for all new projects and consider migrating existing ones. Use preload scripts and IPC for communication between renderer and main processes.
Migrate away from the `remote` module. Instead, use secure patterns like IPC (Inter-Process Communication) via `ipcRenderer` and `ipcMain`, often facilitated by a sandboxed preload script, to expose necessary main process functionalities to the renderer.
Regularly check the official Electron documentation and release notes. Monitor your application's console for deprecation warnings during development and testing, and update your code accordingly.
Use official tools like `electron-builder` or `electron-packager`. Ensure native modules are rebuilt for Electron's specific Node.js version and architecture. Test builds thoroughly on all target platforms.
For an ESM module, use `import()` dynamically or ensure your main process entry file is an ES Module (e.g., `"type": "module"` in `package.json` and use `.mjs` extension) to use top-level `import` statements. Or, find a CommonJS compatible version of the dependency.
Access Node.js APIs and other main process functionalities securely via a preload script with `contextIsolation: true`. Expose necessary functions from the preload script to the renderer's `window` object, or use `ipcRenderer` to communicate with the main process.
Ensure `contextIsolation: true` is set in `webPreferences`. In your `preload.js` script, use `contextBridge.exposeInMainWorld` to selectively expose an API to the renderer process, which then uses `window.myAPI.send(...)` or `window.myAPI.invoke(...)`.
No dependency data recorded yet.