Breaking Changes

Breaking changes will be documented here, and deprecation warnings added to JS code where possible, at least one major version before the change is made.

Types of Breaking Changes

This document uses the following convention to categorize breaking changes:

  • API Changed: An API was changed in such a way that code that has not been updated is guaranteed to throw an exception.
  • Behavior Changed: The behavior of Electron has changed, but not in such a way that an exception will necessarily be thrown.
  • Default Changed: Code depending on the old default may break, not necessarily throwing an exception. The old behavior can be restored by explicitly specifying the value.
  • Deprecated: An API was marked as deprecated. The API will continue to function, but will emit a deprecation warning, and will be removed in a future release.
  • Removed: An API or feature was removed, and is no longer supported by Electron.

Planned Breaking API Changes (27.0)

Removed: macOS 10.13 / 10.14 support

macOS 10.13 (High Sierra) and macOS 10.14 (Mojave) are no longer supported by Chromium.

Older versions of Electron will continue to run on these operating systems, but macOS 10.15 (Catalina) or later will be required to run Electron v27.0.0 and higher.

Deprecated: ipcRenderer.sendTo()

The ipcRenderer.sendTo() API has been deprecated. It should be replaced by setting up a MessageChannel between the renderers.

The senderId and senderIsMainFrame properties of IpcRendererEvent have been deprecated as well.

Removed: color scheme events in systemPreferences

The following systemPreferences events have been removed:

  • inverted-color-scheme-changed
  • high-contrast-color-scheme-changed

Use the new updated event on the nativeTheme module instead.

  1. // Removed
  2. systemPreferences.on('inverted-color-scheme-changed', () => { /* ... */ })
  3. systemPreferences.on('high-contrast-color-scheme-changed', () => { /* ... */ })
  4. // Replace with
  5. nativeTheme.on('updated', () => { /* ... */ })

Removed: webContents.getPrinters

The webContents.getPrinters method has been removed. Use webContents.getPrintersAsync instead.

  1. const w = new BrowserWindow({ show: false })
  2. // Removed
  3. console.log(w.webContents.getPrinters())
  4. // Replace with
  5. w.webContents.getPrintersAsync().then((printers) => {
  6. console.log(printers)
  7. })

Removed: systemPreferences.{get,set}AppLevelAppearance and systemPreferences.appLevelAppearance

The systemPreferences.getAppLevelAppearance and systemPreferences.setAppLevelAppearance methods have been removed, as well as the systemPreferences.appLevelAppearance property. Use the nativeTheme module instead.

  1. // Removed
  2. systemPreferences.getAppLevelAppearance()
  3. // Replace with
  4. nativeTheme.shouldUseDarkColors
  5. // Removed
  6. systemPreferences.appLevelAppearance
  7. // Replace with
  8. nativeTheme.shouldUseDarkColors
  9. // Removed
  10. systemPreferences.setAppLevelAppearance('dark')
  11. // Replace with
  12. nativeTheme.themeSource = 'dark'

Removed: alternate-selected-control-text value for systemPreferences.getColor

The alternate-selected-control-text value for systemPreferences.getColor has been removed. Use selected-content-background instead.

  1. // Removed
  2. systemPreferences.getColor('alternate-selected-control-text')
  3. // Replace with
  4. systemPreferences.getColor('selected-content-background')

Planned Breaking API Changes (26.0)

Deprecated: webContents.getPrinters

The webContents.getPrinters method has been deprecated. Use webContents.getPrintersAsync instead.

  1. const w = new BrowserWindow({ show: false })
  2. // Deprecated
  3. console.log(w.webContents.getPrinters())
  4. // Replace with
  5. w.webContents.getPrintersAsync().then((printers) => {
  6. console.log(printers)
  7. })

Deprecated: systemPreferences.{get,set}AppLevelAppearance and systemPreferences.appLevelAppearance

The systemPreferences.getAppLevelAppearance and systemPreferences.setAppLevelAppearance methods have been deprecated, as well as the systemPreferences.appLevelAppearance property. Use the nativeTheme module instead.

  1. // Deprecated
  2. systemPreferences.getAppLevelAppearance()
  3. // Replace with
  4. nativeTheme.shouldUseDarkColors
  5. // Deprecated
  6. systemPreferences.appLevelAppearance
  7. // Replace with
  8. nativeTheme.shouldUseDarkColors
  9. // Deprecated
  10. systemPreferences.setAppLevelAppearance('dark')
  11. // Replace with
  12. nativeTheme.themeSource = 'dark'

Deprecated: alternate-selected-control-text value for systemPreferences.getColor

The alternate-selected-control-text value for systemPreferences.getColor has been deprecated. Use selected-content-background instead.

  1. // Deprecated
  2. systemPreferences.getColor('alternate-selected-control-text')
  3. // Replace with
  4. systemPreferences.getColor('selected-content-background')

Planned Breaking API Changes (25.0)

Deprecated: protocol.{register,intercept}{Buffer,String,Stream,File,Http}Protocol

The protocol.register*Protocol and protocol.intercept*Protocol methods have been replaced with protocol.handle.

The new method can either register a new protocol or intercept an existing protocol, and responses can be of any type.

  1. // Deprecated in Electron 25
  2. protocol.registerBufferProtocol('some-protocol', () => {
  3. callback({ mimeType: 'text/html', data: Buffer.from('<h5>Response</h5>') })
  4. })
  5. // Replace with
  6. protocol.handle('some-protocol', () => {
  7. return new Response(
  8. Buffer.from('<h5>Response</h5>'), // Could also be a string or ReadableStream.
  9. { headers: { 'content-type': 'text/html' } }
  10. )
  11. })
  1. // Deprecated in Electron 25
  2. protocol.registerHttpProtocol('some-protocol', () => {
  3. callback({ url: 'https://electronjs.org' })
  4. })
  5. // Replace with
  6. protocol.handle('some-protocol', () => {
  7. return net.fetch('https://electronjs.org')
  8. })
  1. // Deprecated in Electron 25
  2. protocol.registerFileProtocol('some-protocol', () => {
  3. callback({ filePath: '/path/to/my/file' })
  4. })
  5. // Replace with
  6. protocol.handle('some-protocol', () => {
  7. return net.fetch('file:///path/to/my/file')
  8. })

Deprecated: BrowserWindow.setTrafficLightPosition(position)

BrowserWindow.setTrafficLightPosition(position) has been deprecated, the BrowserWindow.setWindowButtonPosition(position) API should be used instead which accepts null instead of { x: 0, y: 0 } to reset the position to system default.

  1. // Deprecated in Electron 25
  2. win.setTrafficLightPosition({ x: 10, y: 10 })
  3. win.setTrafficLightPosition({ x: 0, y: 0 })
  4. // Replace with
  5. win.setWindowButtonPosition({ x: 10, y: 10 })
  6. win.setWindowButtonPosition(null)

Deprecated: BrowserWindow.getTrafficLightPosition()

BrowserWindow.getTrafficLightPosition() has been deprecated, the BrowserWindow.getWindowButtonPosition() API should be used instead which returns null instead of { x: 0, y: 0 } when there is no custom position.

  1. // Deprecated in Electron 25
  2. const pos = win.getTrafficLightPosition()
  3. if (pos.x === 0 && pos.y === 0) {
  4. // No custom position.
  5. }
  6. // Replace with
  7. const ret = win.getWindowButtonPosition()
  8. if (ret === null) {
  9. // No custom position.
  10. }

Planned Breaking API Changes (24.0)

API Changed: nativeImage.createThumbnailFromPath(path, size)

The maxSize parameter has been changed to size to reflect that the size passed in will be the size the thumbnail created. Previously, Windows would not scale the image up if it were smaller than maxSize, and macOS would always set the size to maxSize. Behavior is now the same across platforms.

Updated Behavior:

  1. // a 128x128 image.
  2. const imagePath = path.join('path', 'to', 'capybara.png')
  3. // Scaling up a smaller image.
  4. const upSize = { width: 256, height: 256 }
  5. nativeImage.createThumbnailFromPath(imagePath, upSize).then(result => {
  6. console.log(result.getSize()) // { width: 256, height: 256 }
  7. })
  8. // Scaling down a larger image.
  9. const downSize = { width: 64, height: 64 }
  10. nativeImage.createThumbnailFromPath(imagePath, downSize).then(result => {
  11. console.log(result.getSize()) // { width: 64, height: 64 }
  12. })

Previous Behavior (on Windows):

  1. // a 128x128 image
  2. const imagePath = path.join('path', 'to', 'capybara.png')
  3. const size = { width: 256, height: 256 }
  4. nativeImage.createThumbnailFromPath(imagePath, size).then(result => {
  5. console.log(result.getSize()) // { width: 128, height: 128 }
  6. })

Planned Breaking API Changes (23.0)

Behavior Changed: Draggable Regions on macOS

The implementation of draggable regions (using the CSS property -webkit-app-region: drag) has changed on macOS to bring it in line with Windows and Linux. Previously, when a region with -webkit-app-region: no-drag overlapped a region with -webkit-app-region: drag, the no-drag region would always take precedence on macOS, regardless of CSS layering. That is, if a drag region was above a no-drag region, it would be ignored. Beginning in Electron 23, a drag region on top of a no-drag region will correctly cause the region to be draggable.

Additionally, the customButtonsOnHover BrowserWindow property previously created a draggable region which ignored the -webkit-app-region CSS property. This has now been fixed (see #37210 for discussion).

As a result, if your app uses a frameless window with draggable regions on macOS, the regions which are draggable in your app may change in Electron 23.

Removed: Windows 7 / 8 / 8.1 support

Windows 7, Windows 8, and Windows 8.1 are no longer supported. Electron follows the planned Chromium deprecation policy, which will deprecate Windows 7 support beginning in Chromium 109.

Older versions of Electron will continue to run on these operating systems, but Windows 10 or later will be required to run Electron v23.0.0 and higher.

Removed: BrowserWindow scroll-touch-* events

The deprecated scroll-touch-begin, scroll-touch-end and scroll-touch-edge events on BrowserWindow have been removed. Instead, use the newly available input-event event on WebContents.

  1. // Removed in Electron 23.0
  2. win.on('scroll-touch-begin', scrollTouchBegin)
  3. win.on('scroll-touch-edge', scrollTouchEdge)
  4. win.on('scroll-touch-end', scrollTouchEnd)
  5. // Replace with
  6. win.webContents.on('input-event', (_, event) => {
  7. if (event.type === 'gestureScrollBegin') {
  8. scrollTouchBegin()
  9. } else if (event.type === 'gestureScrollUpdate') {
  10. scrollTouchEdge()
  11. } else if (event.type === 'gestureScrollEnd') {
  12. scrollTouchEnd()
  13. }
  14. })

Removed: webContents.incrementCapturerCount(stayHidden, stayAwake)

The webContents.incrementCapturerCount(stayHidden, stayAwake) function has been removed. It is now automatically handled by webContents.capturePage when a page capture completes.

  1. const w = new BrowserWindow({ show: false })
  2. // Removed in Electron 23
  3. w.webContents.incrementCapturerCount()
  4. w.capturePage().then(image => {
  5. console.log(image.toDataURL())
  6. w.webContents.decrementCapturerCount()
  7. })
  8. // Replace with
  9. w.capturePage().then(image => {
  10. console.log(image.toDataURL())
  11. })

Removed: webContents.decrementCapturerCount(stayHidden, stayAwake)

The webContents.decrementCapturerCount(stayHidden, stayAwake) function has been removed. It is now automatically handled by webContents.capturePage when a page capture completes.

  1. const w = new BrowserWindow({ show: false })
  2. // Removed in Electron 23
  3. w.webContents.incrementCapturerCount()
  4. w.capturePage().then(image => {
  5. console.log(image.toDataURL())
  6. w.webContents.decrementCapturerCount()
  7. })
  8. // Replace with
  9. w.capturePage().then(image => {
  10. console.log(image.toDataURL())
  11. })

Planned Breaking API Changes (22.0)

Deprecated: webContents.incrementCapturerCount(stayHidden, stayAwake)

webContents.incrementCapturerCount(stayHidden, stayAwake) has been deprecated. It is now automatically handled by webContents.capturePage when a page capture completes.

  1. const w = new BrowserWindow({ show: false })
  2. // Removed in Electron 23
  3. w.webContents.incrementCapturerCount()
  4. w.capturePage().then(image => {
  5. console.log(image.toDataURL())
  6. w.webContents.decrementCapturerCount()
  7. })
  8. // Replace with
  9. w.capturePage().then(image => {
  10. console.log(image.toDataURL())
  11. })

Deprecated: webContents.decrementCapturerCount(stayHidden, stayAwake)

webContents.decrementCapturerCount(stayHidden, stayAwake) has been deprecated. It is now automatically handled by webContents.capturePage when a page capture completes.

  1. const w = new BrowserWindow({ show: false })
  2. // Removed in Electron 23
  3. w.webContents.incrementCapturerCount()
  4. w.capturePage().then(image => {
  5. console.log(image.toDataURL())
  6. w.webContents.decrementCapturerCount()
  7. })
  8. // Replace with
  9. w.capturePage().then(image => {
  10. console.log(image.toDataURL())
  11. })

Removed: WebContents new-window event

The new-window event of WebContents has been removed. It is replaced by webContents.setWindowOpenHandler().

  1. // Removed in Electron 22
  2. webContents.on('new-window', (event) => {
  3. event.preventDefault()
  4. })
  5. // Replace with
  6. webContents.setWindowOpenHandler((details) => {
  7. return { action: 'deny' }
  8. })

Removed: <webview> new-window event

The new-window event of <webview> has been removed. There is no direct replacement.

  1. // Removed in Electron 22
  2. webview.addEventListener('new-window', (event) => {})

docs/fiddles/ipc/webview-new-window (27.0.1)Open in Fiddle

  • child.html
  • main.js
  • preload.js
  • index.html
  • renderer.js
  1. <body>
  2. <a href="child.html" target="_blank">new window</a>
  3. </body>
  1. // Modules to control application life and create native browser window
  2. const { app, BrowserWindow } = require('electron')
  3. const path = require('node:path')
  4. function createWindow () {
  5. // Create the browser window.
  6. const mainWindow = new BrowserWindow({
  7. width: 800,
  8. height: 600,
  9. webPreferences: {
  10. preload: path.join(__dirname, 'preload.js'),
  11. webviewTag: true
  12. }
  13. })
  14. mainWindow.webContents.on('did-attach-webview', (event, wc) => {
  15. wc.setWindowOpenHandler((details) => {
  16. mainWindow.webContents.send('webview-new-window', wc.id, details)
  17. return { action: 'deny' }
  18. })
  19. })
  20. // and load the index.html of the app.
  21. mainWindow.loadFile('index.html')
  22. // Open the DevTools.
  23. // mainWindow.webContents.openDevTools()
  24. }
  25. // This method will be called when Electron has finished
  26. // initialization and is ready to create browser windows.
  27. // Some APIs can only be used after this event occurs.
  28. app.whenReady().then(() => {
  29. createWindow()
  30. app.on('activate', function () {
  31. // On macOS it's common to re-create a window in the app when the
  32. // dock icon is clicked and there are no other windows open.
  33. if (BrowserWindow.getAllWindows().length === 0) createWindow()
  34. })
  35. })
  36. // Quit when all windows are closed, except on macOS. There, it's common
  37. // for applications and their menu bar to stay active until the user quits
  38. // explicitly with Cmd + Q.
  39. app.on('window-all-closed', function () {
  40. if (process.platform !== 'darwin') app.quit()
  41. })
  42. // In this file you can include the rest of your app's specific main process
  43. // code. You can also put them in separate files and require them here.
  1. const { ipcRenderer } = require('electron')
  2. const webview = document.getElementById('webview')
  3. ipcRenderer.on('webview-new-window', (e, webContentsId, details) => {
  4. console.log('webview-new-window', webContentsId, details)
  5. webview.dispatchEvent(new Event('new-window'))
  6. })
  1. <body>
  2. <webview id=webview src="child.html" allowpopups></webview>
  3. <script src="renderer.js"></script>
  4. </body>
  1. const webview = document.getElementById('webview')
  2. webview.addEventListener('new-window', () => {
  3. console.log('got new-window event')
  4. })

Deprecated: BrowserWindow scroll-touch-* events

The scroll-touch-begin, scroll-touch-end and scroll-touch-edge events on BrowserWindow are deprecated. Instead, use the newly available input-event event on WebContents.

  1. // Deprecated
  2. win.on('scroll-touch-begin', scrollTouchBegin)
  3. win.on('scroll-touch-edge', scrollTouchEdge)
  4. win.on('scroll-touch-end', scrollTouchEnd)
  5. // Replace with
  6. win.webContents.on('input-event', (_, event) => {
  7. if (event.type === 'gestureScrollBegin') {
  8. scrollTouchBegin()
  9. } else if (event.type === 'gestureScrollUpdate') {
  10. scrollTouchEdge()
  11. } else if (event.type === 'gestureScrollEnd') {
  12. scrollTouchEnd()
  13. }
  14. })

Planned Breaking API Changes (21.0)

Behavior Changed: V8 Memory Cage enabled

The V8 memory cage has been enabled, which has implications for native modules which wrap non-V8 memory with ArrayBuffer or Buffer. See the blog post about the V8 memory cage for more details.

API Changed: webContents.printToPDF()

webContents.printToPDF() has been modified to conform to Page.printToPDF in the Chrome DevTools Protocol. This has been changes in order to address changes upstream that made our previous implementation untenable and rife with bugs.

Arguments Changed

  • pageRanges

Arguments Removed

  • printSelectionOnly
  • marginsType
  • headerFooter
  • scaleFactor

Arguments Added

  • headerTemplate
  • footerTemplate
  • displayHeaderFooter
  • margins
  • scale
  • preferCSSPageSize
  1. // Main process
  2. const { webContents } = require('electron')
  3. webContents.printToPDF({
  4. landscape: true,
  5. displayHeaderFooter: true,
  6. printBackground: true,
  7. scale: 2,
  8. pageSize: 'Ledger',
  9. margins: {
  10. top: 2,
  11. bottom: 2,
  12. left: 2,
  13. right: 2
  14. },
  15. pageRanges: '1-5, 8, 11-13',
  16. headerTemplate: '<h1>Title</h1>',
  17. footerTemplate: '<div><span class="pageNumber"></span></div>',
  18. preferCSSPageSize: true
  19. }).then(data => {
  20. fs.writeFile(pdfPath, data, (error) => {
  21. if (error) throw error
  22. console.log(`Wrote PDF successfully to ${pdfPath}`)
  23. })
  24. }).catch(error => {
  25. console.log(`Failed to write PDF to ${pdfPath}: `, error)
  26. })

Planned Breaking API Changes (20.0)

Removed: macOS 10.11 / 10.12 support

macOS 10.11 (El Capitan) and macOS 10.12 (Sierra) are no longer supported by Chromium.

Older versions of Electron will continue to run on these operating systems, but macOS 10.13 (High Sierra) or later will be required to run Electron v20.0.0 and higher.

Default Changed: renderers without nodeIntegration: true are sandboxed by default

Previously, renderers that specified a preload script defaulted to being unsandboxed. This meant that by default, preload scripts had access to Node.js. In Electron 20, this default has changed. Beginning in Electron 20, renderers will be sandboxed by default, unless nodeIntegration: true or sandbox: false is specified.

If your preload scripts do not depend on Node, no action is needed. If your preload scripts do depend on Node, either refactor them to remove Node usage from the renderer, or explicitly specify sandbox: false for the relevant renderers.

Removed: skipTaskbar on Linux

On X11, skipTaskbar sends a _NET_WM_STATE_SKIP_TASKBAR message to the X11 window manager. There is not a direct equivalent for Wayland, and the known workarounds have unacceptable tradeoffs (e.g. Window.is_skip_taskbar in GNOME requires unsafe mode), so Electron is unable to support this feature on Linux.

API Changed: session.setDevicePermissionHandler(handler)

The handler invoked when session.setDevicePermissionHandler(handler) is used has a change to its arguments. This handler no longer is passed a frame WebFrameMain, but instead is passed the origin, which is the origin that is checking for device permission.

Planned Breaking API Changes (19.0)

Removed: IA32 Linux binaries

This is a result of Chromium 102.0.4999.0 dropping support for IA32 Linux. This concludes the removal of support for IA32 Linux.

Planned Breaking API Changes (18.0)

Removed: nativeWindowOpen

Prior to Electron 15, window.open was by default shimmed to use BrowserWindowProxy. This meant that window.open('about:blank') did not work to open synchronously scriptable child windows, among other incompatibilities. Since Electron 15, nativeWindowOpen has been enabled by default.

See the documentation for window.open in Electron for more details.

Planned Breaking API Changes (17.0)

Removed: desktopCapturer.getSources in the renderer

The desktopCapturer.getSources API is now only available in the main process. This has been changed in order to improve the default security of Electron apps.

If you need this functionality, it can be replaced as follows:

  1. // Main process
  2. const { ipcMain, desktopCapturer } = require('electron')
  3. ipcMain.handle(
  4. 'DESKTOP_CAPTURER_GET_SOURCES',
  5. (event, opts) => desktopCapturer.getSources(opts)
  6. )
  1. // Renderer process
  2. const { ipcRenderer } = require('electron')
  3. const desktopCapturer = {
  4. getSources: (opts) => ipcRenderer.invoke('DESKTOP_CAPTURER_GET_SOURCES', opts)
  5. }

However, you should consider further restricting the information returned to the renderer; for instance, displaying a source selector to the user and only returning the selected source.

Deprecated: nativeWindowOpen

Prior to Electron 15, window.open was by default shimmed to use BrowserWindowProxy. This meant that window.open('about:blank') did not work to open synchronously scriptable child windows, among other incompatibilities. Since Electron 15, nativeWindowOpen has been enabled by default.

See the documentation for window.open in Electron for more details.

Planned Breaking API Changes (16.0)

Behavior Changed: crashReporter implementation switched to Crashpad on Linux

The underlying implementation of the crashReporter API on Linux has changed from Breakpad to Crashpad, bringing it in line with Windows and Mac. As a result of this, child processes are now automatically monitored, and calling process.crashReporter.start in Node child processes is no longer needed (and is not advisable, as it will start a second instance of the Crashpad reporter).

There are also some subtle changes to how annotations will be reported on Linux, including that long values will no longer be split between annotations appended with __1, __2 and so on, and instead will be truncated at the (new, longer) annotation value limit.

Deprecated: desktopCapturer.getSources in the renderer

Usage of the desktopCapturer.getSources API in the renderer has been deprecated and will be removed. This change improves the default security of Electron apps.

See here for details on how to replace this API in your app.

Planned Breaking API Changes (15.0)

Default Changed: nativeWindowOpen defaults to true

Prior to Electron 15, window.open was by default shimmed to use BrowserWindowProxy. This meant that window.open('about:blank') did not work to open synchronously scriptable child windows, among other incompatibilities. nativeWindowOpen is no longer experimental, and is now the default.

See the documentation for window.open in Electron for more details.

Deprecated: app.runningUnderRosettaTranslation

The app.runningUnderRosettaTranslation property has been deprecated. Use app.runningUnderARM64Translation instead.

  1. // Deprecated
  2. console.log(app.runningUnderRosettaTranslation)
  3. // Replace with
  4. console.log(app.runningUnderARM64Translation)

Planned Breaking API Changes (14.0)

Removed: remote module

The remote module was deprecated in Electron 12, and will be removed in Electron 14. It is replaced by the @electron/remote module.

  1. // Deprecated in Electron 12:
  2. const { BrowserWindow } = require('electron').remote
  1. // Replace with:
  2. const { BrowserWindow } = require('@electron/remote')
  3. // In the main process:
  4. require('@electron/remote/main').initialize()

Removed: app.allowRendererProcessReuse

The app.allowRendererProcessReuse property will be removed as part of our plan to more closely align with Chromium’s process model for security, performance and maintainability.

For more detailed information see #18397.

Removed: Browser Window Affinity

The affinity option when constructing a new BrowserWindow will be removed as part of our plan to more closely align with Chromium’s process model for security, performance and maintainability.

For more detailed information see #18397.

API Changed: window.open()

The optional parameter frameName will no longer set the title of the window. This now follows the specification described by the native documentation under the corresponding parameter windowName.

If you were using this parameter to set the title of a window, you can instead use win.setTitle(title).

Removed: worldSafeExecuteJavaScript

In Electron 14, worldSafeExecuteJavaScript will be removed. There is no alternative, please ensure your code works with this property enabled. It has been enabled by default since Electron 12.

You will be affected by this change if you use either webFrame.executeJavaScript or webFrame.executeJavaScriptInIsolatedWorld. You will need to ensure that values returned by either of those methods are supported by the Context Bridge API as these methods use the same value passing semantics.

Removed: BrowserWindowConstructorOptions inheriting from parent windows

Prior to Electron 14, windows opened with window.open would inherit BrowserWindow constructor options such as transparent and resizable from their parent window. Beginning with Electron 14, this behavior is removed, and windows will not inherit any BrowserWindow constructor options from their parents.

Instead, explicitly set options for the new window with setWindowOpenHandler:

  1. webContents.setWindowOpenHandler((details) => {
  2. return {
  3. action: 'allow',
  4. overrideBrowserWindowOptions: {
  5. // ...
  6. }
  7. }
  8. })

Removed: additionalFeatures

The deprecated additionalFeatures property in the new-window and did-create-window events of WebContents has been removed. Since new-window uses positional arguments, the argument is still present, but will always be the empty array []. (Though note, the new-window event itself is deprecated, and is replaced by setWindowOpenHandler.) Bare keys in window features will now present as keys with the value true in the options object.

  1. // Removed in Electron 14
  2. // Triggered by window.open('...', '', 'my-key')
  3. webContents.on('did-create-window', (window, details) => {
  4. if (details.additionalFeatures.includes('my-key')) {
  5. // ...
  6. }
  7. })
  8. // Replace with
  9. webContents.on('did-create-window', (window, details) => {
  10. if (details.options['my-key']) {
  11. // ...
  12. }
  13. })

Planned Breaking API Changes (13.0)

API Changed: session.setPermissionCheckHandler(handler)

The handler methods first parameter was previously always a webContents, it can now sometimes be null. You should use the requestingOrigin, embeddingOrigin and securityOrigin properties to respond to the permission check correctly. As the webContents can be null it can no longer be relied on.

  1. // Old code
  2. session.setPermissionCheckHandler((webContents, permission) => {
  3. if (webContents.getURL().startsWith('https://google.com/') && permission === 'notification') {
  4. return true
  5. }
  6. return false
  7. })
  8. // Replace with
  9. session.setPermissionCheckHandler((webContents, permission, requestingOrigin) => {
  10. if (new URL(requestingOrigin).hostname === 'google.com' && permission === 'notification') {
  11. return true
  12. }
  13. return false
  14. })

Removed: shell.moveItemToTrash()

The deprecated synchronous shell.moveItemToTrash() API has been removed. Use the asynchronous shell.trashItem() instead.

  1. // Removed in Electron 13
  2. shell.moveItemToTrash(path)
  3. // Replace with
  4. shell.trashItem(path).then(/* ... */)

Removed: BrowserWindow extension APIs

The deprecated extension APIs have been removed:

  • BrowserWindow.addExtension(path)
  • BrowserWindow.addDevToolsExtension(path)
  • BrowserWindow.removeExtension(name)
  • BrowserWindow.removeDevToolsExtension(name)
  • BrowserWindow.getExtensions()
  • BrowserWindow.getDevToolsExtensions()

Use the session APIs instead:

  • ses.loadExtension(path)
  • ses.removeExtension(extension_id)
  • ses.getAllExtensions()
  1. // Removed in Electron 13
  2. BrowserWindow.addExtension(path)
  3. BrowserWindow.addDevToolsExtension(path)
  4. // Replace with
  5. session.defaultSession.loadExtension(path)
  1. // Removed in Electron 13
  2. BrowserWindow.removeExtension(name)
  3. BrowserWindow.removeDevToolsExtension(name)
  4. // Replace with
  5. session.defaultSession.removeExtension(extension_id)
  1. // Removed in Electron 13
  2. BrowserWindow.getExtensions()
  3. BrowserWindow.getDevToolsExtensions()
  4. // Replace with
  5. session.defaultSession.getAllExtensions()

Removed: methods in systemPreferences

The following systemPreferences methods have been deprecated:

  • systemPreferences.isDarkMode()
  • systemPreferences.isInvertedColorScheme()
  • systemPreferences.isHighContrastColorScheme()

Use the following nativeTheme properties instead:

  • nativeTheme.shouldUseDarkColors
  • nativeTheme.shouldUseInvertedColorScheme
  • nativeTheme.shouldUseHighContrastColors
  1. // Removed in Electron 13
  2. systemPreferences.isDarkMode()
  3. // Replace with
  4. nativeTheme.shouldUseDarkColors
  5. // Removed in Electron 13
  6. systemPreferences.isInvertedColorScheme()
  7. // Replace with
  8. nativeTheme.shouldUseInvertedColorScheme
  9. // Removed in Electron 13
  10. systemPreferences.isHighContrastColorScheme()
  11. // Replace with
  12. nativeTheme.shouldUseHighContrastColors

Deprecated: WebContents new-window event

The new-window event of WebContents has been deprecated. It is replaced by webContents.setWindowOpenHandler().

  1. // Deprecated in Electron 13
  2. webContents.on('new-window', (event) => {
  3. event.preventDefault()
  4. })
  5. // Replace with
  6. webContents.setWindowOpenHandler((details) => {
  7. return { action: 'deny' }
  8. })

Planned Breaking API Changes (12.0)

Removed: Pepper Flash support

Chromium has removed support for Flash, and so we must follow suit. See Chromium’s Flash Roadmap for more details.

Default Changed: worldSafeExecuteJavaScript defaults to true

In Electron 12, worldSafeExecuteJavaScript will be enabled by default. To restore the previous behavior, worldSafeExecuteJavaScript: false must be specified in WebPreferences. Please note that setting this option to false is insecure.

This option will be removed in Electron 14 so please migrate your code to support the default value.

Default Changed: contextIsolation defaults to true

In Electron 12, contextIsolation will be enabled by default. To restore the previous behavior, contextIsolation: false must be specified in WebPreferences.

We recommend having contextIsolation enabled for the security of your application.

Another implication is that require() cannot be used in the renderer process unless nodeIntegration is true and contextIsolation is false.

For more details see: https://github.com/electron/electron/issues/23506

Removed: crashReporter.getCrashesDirectory()

The crashReporter.getCrashesDirectory method has been removed. Usage should be replaced by app.getPath('crashDumps').

  1. // Removed in Electron 12
  2. crashReporter.getCrashesDirectory()
  3. // Replace with
  4. app.getPath('crashDumps')

Removed: crashReporter methods in the renderer process

The following crashReporter methods are no longer available in the renderer process:

  • crashReporter.start
  • crashReporter.getLastCrashReport
  • crashReporter.getUploadedReports
  • crashReporter.getUploadToServer
  • crashReporter.setUploadToServer
  • crashReporter.getCrashesDirectory

They should be called only from the main process.

See #23265 for more details.

Default Changed: crashReporter.start({ compress: true })

The default value of the compress option to crashReporter.start has changed from false to true. This means that crash dumps will be uploaded to the crash ingestion server with the Content-Encoding: gzip header, and the body will be compressed.

If your crash ingestion server does not support compressed payloads, you can turn off compression by specifying { compress: false } in the crash reporter options.

Deprecated: remote module

The remote module is deprecated in Electron 12, and will be removed in Electron 14. It is replaced by the @electron/remote module.

  1. // Deprecated in Electron 12:
  2. const { BrowserWindow } = require('electron').remote
  1. // Replace with:
  2. const { BrowserWindow } = require('@electron/remote')
  3. // In the main process:
  4. require('@electron/remote/main').initialize()

Deprecated: shell.moveItemToTrash()

The synchronous shell.moveItemToTrash() has been replaced by the new, asynchronous shell.trashItem().

  1. // Deprecated in Electron 12
  2. shell.moveItemToTrash(path)
  3. // Replace with
  4. shell.trashItem(path).then(/* ... */)

Planned Breaking API Changes (11.0)

Removed: BrowserView.{destroy, fromId, fromWebContents, getAllViews} and id property of BrowserView

The experimental APIs BrowserView.{destroy, fromId, fromWebContents, getAllViews} have now been removed. Additionally, the id property of BrowserView has also been removed.

For more detailed information, see #23578.

Planned Breaking API Changes (10.0)

Deprecated: companyName argument to crashReporter.start()

The companyName argument to crashReporter.start(), which was previously required, is now optional, and further, is deprecated. To get the same behavior in a non-deprecated way, you can pass a companyName value in globalExtra.

  1. // Deprecated in Electron 10
  2. crashReporter.start({ companyName: 'Umbrella Corporation' })
  3. // Replace with
  4. crashReporter.start({ globalExtra: { _companyName: 'Umbrella Corporation' } })

Deprecated: crashReporter.getCrashesDirectory()

The crashReporter.getCrashesDirectory method has been deprecated. Usage should be replaced by app.getPath('crashDumps').

  1. // Deprecated in Electron 10
  2. crashReporter.getCrashesDirectory()
  3. // Replace with
  4. app.getPath('crashDumps')

Deprecated: crashReporter methods in the renderer process

Calling the following crashReporter methods from the renderer process is deprecated:

  • crashReporter.start
  • crashReporter.getLastCrashReport
  • crashReporter.getUploadedReports
  • crashReporter.getUploadToServer
  • crashReporter.setUploadToServer
  • crashReporter.getCrashesDirectory

The only non-deprecated methods remaining in the crashReporter module in the renderer are addExtraParameter, removeExtraParameter and getParameters.

All above methods remain non-deprecated when called from the main process.

See #23265 for more details.

Deprecated: crashReporter.start({ compress: false })

Setting { compress: false } in crashReporter.start is deprecated. Nearly all crash ingestion servers support gzip compression. This option will be removed in a future version of Electron.

Default Changed: enableRemoteModule defaults to false

In Electron 9, using the remote module without explicitly enabling it via the enableRemoteModule WebPreferences option began emitting a warning. In Electron 10, the remote module is now disabled by default. To use the remote module, enableRemoteModule: true must be specified in WebPreferences:

  1. const w = new BrowserWindow({
  2. webPreferences: {
  3. enableRemoteModule: true
  4. }
  5. })

We recommend moving away from the remote module.

protocol.unregisterProtocol

protocol.uninterceptProtocol

The APIs are now synchronous and the optional callback is no longer needed.

  1. // Deprecated
  2. protocol.unregisterProtocol(scheme, () => { /* ... */ })
  3. // Replace with
  4. protocol.unregisterProtocol(scheme)

protocol.registerFileProtocol

protocol.registerBufferProtocol

protocol.registerStringProtocol

protocol.registerHttpProtocol

protocol.registerStreamProtocol

protocol.interceptFileProtocol

protocol.interceptStringProtocol

protocol.interceptBufferProtocol

protocol.interceptHttpProtocol

protocol.interceptStreamProtocol

The APIs are now synchronous and the optional callback is no longer needed.

  1. // Deprecated
  2. protocol.registerFileProtocol(scheme, handler, () => { /* ... */ })
  3. // Replace with
  4. protocol.registerFileProtocol(scheme, handler)

The registered or intercepted protocol does not have effect on current page until navigation happens.

protocol.isProtocolHandled

This API is deprecated and users should use protocol.isProtocolRegistered and protocol.isProtocolIntercepted instead.

  1. // Deprecated
  2. protocol.isProtocolHandled(scheme).then(() => { /* ... */ })
  3. // Replace with
  4. const isRegistered = protocol.isProtocolRegistered(scheme)
  5. const isIntercepted = protocol.isProtocolIntercepted(scheme)

Planned Breaking API Changes (9.0)

Default Changed: Loading non-context-aware native modules in the renderer process is disabled by default

As of Electron 9 we do not allow loading of non-context-aware native modules in the renderer process. This is to improve security, performance and maintainability of Electron as a project.

If this impacts you, you can temporarily set app.allowRendererProcessReuse to false to revert to the old behavior. This flag will only be an option until Electron 11 so you should plan to update your native modules to be context aware.

For more detailed information see #18397.

Deprecated: BrowserWindow extension APIs

The following extension APIs have been deprecated:

  • BrowserWindow.addExtension(path)
  • BrowserWindow.addDevToolsExtension(path)
  • BrowserWindow.removeExtension(name)
  • BrowserWindow.removeDevToolsExtension(name)
  • BrowserWindow.getExtensions()
  • BrowserWindow.getDevToolsExtensions()

Use the session APIs instead:

  • ses.loadExtension(path)
  • ses.removeExtension(extension_id)
  • ses.getAllExtensions()
  1. // Deprecated in Electron 9
  2. BrowserWindow.addExtension(path)
  3. BrowserWindow.addDevToolsExtension(path)
  4. // Replace with
  5. session.defaultSession.loadExtension(path)
  1. // Deprecated in Electron 9
  2. BrowserWindow.removeExtension(name)
  3. BrowserWindow.removeDevToolsExtension(name)
  4. // Replace with
  5. session.defaultSession.removeExtension(extension_id)
  1. // Deprecated in Electron 9
  2. BrowserWindow.getExtensions()
  3. BrowserWindow.getDevToolsExtensions()
  4. // Replace with
  5. session.defaultSession.getAllExtensions()

Removed: <webview>.getWebContents()

This API, which was deprecated in Electron 8.0, is now removed.

  1. // Removed in Electron 9.0
  2. webview.getWebContents()
  3. // Replace with
  4. const { remote } = require('electron')
  5. remote.webContents.fromId(webview.getWebContentsId())

Removed: webFrame.setLayoutZoomLevelLimits()

Chromium has removed support for changing the layout zoom level limits, and it is beyond Electron’s capacity to maintain it. The function was deprecated in Electron 8.x, and has been removed in Electron 9.x. The layout zoom level limits are now fixed at a minimum of 0.25 and a maximum of 5.0, as defined here.

Behavior Changed: Sending non-JS objects over IPC now throws an exception

In Electron 8.0, IPC was changed to use the Structured Clone Algorithm, bringing significant performance improvements. To help ease the transition, the old IPC serialization algorithm was kept and used for some objects that aren’t serializable with Structured Clone. In particular, DOM objects (e.g. Element, Location and DOMMatrix), Node.js objects backed by C++ classes (e.g. process.env, some members of Stream), and Electron objects backed by C++ classes (e.g. WebContents, BrowserWindow and WebFrame) are not serializable with Structured Clone. Whenever the old algorithm was invoked, a deprecation warning was printed.

In Electron 9.0, the old serialization algorithm has been removed, and sending such non-serializable objects will now throw an “object could not be cloned” error.

API Changed: shell.openItem is now shell.openPath

The shell.openItem API has been replaced with an asynchronous shell.openPath API. You can see the original API proposal and reasoning here.

Planned Breaking API Changes (8.0)

Behavior Changed: Values sent over IPC are now serialized with Structured Clone Algorithm

The algorithm used to serialize objects sent over IPC (through ipcRenderer.send, ipcRenderer.sendSync, WebContents.send and related methods) has been switched from a custom algorithm to V8’s built-in Structured Clone Algorithm, the same algorithm used to serialize messages for postMessage. This brings about a 2x performance improvement for large messages, but also brings some breaking changes in behavior.

  • Sending Functions, Promises, WeakMaps, WeakSets, or objects containing any such values, over IPC will now throw an exception, instead of silently converting the functions to undefined.
  1. // Previously:
  2. ipcRenderer.send('channel', { value: 3, someFunction: () => {} })
  3. // => results in { value: 3 } arriving in the main process
  4. // From Electron 8:
  5. ipcRenderer.send('channel', { value: 3, someFunction: () => {} })
  6. // => throws Error("() => {} could not be cloned.")
  • NaN, Infinity and -Infinity will now be correctly serialized, instead of being converted to null.
  • Objects containing cyclic references will now be correctly serialized, instead of being converted to null.
  • Set, Map, Error and RegExp values will be correctly serialized, instead of being converted to {}.
  • BigInt values will be correctly serialized, instead of being converted to null.
  • Sparse arrays will be serialized as such, instead of being converted to dense arrays with nulls.
  • Date objects will be transferred as Date objects, instead of being converted to their ISO string representation.
  • Typed Arrays (such as Uint8Array, Uint16Array, Uint32Array and so on) will be transferred as such, instead of being converted to Node.js Buffer.
  • Node.js Buffer objects will be transferred as Uint8Arrays. You can convert a Uint8Array back to a Node.js Buffer by wrapping the underlying ArrayBuffer:
  1. Buffer.from(value.buffer, value.byteOffset, value.byteLength)

Sending any objects that aren’t native JS types, such as DOM objects (e.g. Element, Location, DOMMatrix), Node.js objects (e.g. process.env, Stream), or Electron objects (e.g. WebContents, BrowserWindow, WebFrame) is deprecated. In Electron 8, these objects will be serialized as before with a DeprecationWarning message, but starting in Electron 9, sending these kinds of objects will throw a ‘could not be cloned’ error.

Deprecated: <webview>.getWebContents()

This API is implemented using the remote module, which has both performance and security implications. Therefore its usage should be explicit.

  1. // Deprecated
  2. webview.getWebContents()
  3. // Replace with
  4. const { remote } = require('electron')
  5. remote.webContents.fromId(webview.getWebContentsId())

However, it is recommended to avoid using the remote module altogether.

  1. // main
  2. const { ipcMain, webContents } = require('electron')
  3. const getGuestForWebContents = (webContentsId, contents) => {
  4. const guest = webContents.fromId(webContentsId)
  5. if (!guest) {
  6. throw new Error(`Invalid webContentsId: ${webContentsId}`)
  7. }
  8. if (guest.hostWebContents !== contents) {
  9. throw new Error('Access denied to webContents')
  10. }
  11. return guest
  12. }
  13. ipcMain.handle('openDevTools', (event, webContentsId) => {
  14. const guest = getGuestForWebContents(webContentsId, event.sender)
  15. guest.openDevTools()
  16. })
  17. // renderer
  18. const { ipcRenderer } = require('electron')
  19. ipcRenderer.invoke('openDevTools', webview.getWebContentsId())

Deprecated: webFrame.setLayoutZoomLevelLimits()

Chromium has removed support for changing the layout zoom level limits, and it is beyond Electron’s capacity to maintain it. The function will emit a warning in Electron 8.x, and cease to exist in Electron 9.x. The layout zoom level limits are now fixed at a minimum of 0.25 and a maximum of 5.0, as defined here.

Deprecated events in systemPreferences

The following systemPreferences events have been deprecated:

  • inverted-color-scheme-changed
  • high-contrast-color-scheme-changed

Use the new updated event on the nativeTheme module instead.

  1. // Deprecated
  2. systemPreferences.on('inverted-color-scheme-changed', () => { /* ... */ })
  3. systemPreferences.on('high-contrast-color-scheme-changed', () => { /* ... */ })
  4. // Replace with
  5. nativeTheme.on('updated', () => { /* ... */ })

Deprecated: methods in systemPreferences

The following systemPreferences methods have been deprecated:

  • systemPreferences.isDarkMode()
  • systemPreferences.isInvertedColorScheme()
  • systemPreferences.isHighContrastColorScheme()

Use the following nativeTheme properties instead:

  • nativeTheme.shouldUseDarkColors
  • nativeTheme.shouldUseInvertedColorScheme
  • nativeTheme.shouldUseHighContrastColors
  1. // Deprecated
  2. systemPreferences.isDarkMode()
  3. // Replace with
  4. nativeTheme.shouldUseDarkColors
  5. // Deprecated
  6. systemPreferences.isInvertedColorScheme()
  7. // Replace with
  8. nativeTheme.shouldUseInvertedColorScheme
  9. // Deprecated
  10. systemPreferences.isHighContrastColorScheme()
  11. // Replace with
  12. nativeTheme.shouldUseHighContrastColors

Planned Breaking API Changes (7.0)

Deprecated: Atom.io Node Headers URL

This is the URL specified as disturl in a .npmrc file or as the --dist-url command line flag when building native Node modules. Both will be supported for the foreseeable future but it is recommended that you switch.

Deprecated: https://atom.io/download/electron

Replace with: https://electronjs.org/headers

API Changed: session.clearAuthCache() no longer accepts options

The session.clearAuthCache API no longer accepts options for what to clear, and instead unconditionally clears the whole cache.

  1. // Deprecated
  2. session.clearAuthCache({ type: 'password' })
  3. // Replace with
  4. session.clearAuthCache()

API Changed: powerMonitor.querySystemIdleState is now powerMonitor.getSystemIdleState

  1. // Removed in Electron 7.0
  2. powerMonitor.querySystemIdleState(threshold, callback)
  3. // Replace with synchronous API
  4. const idleState = powerMonitor.getSystemIdleState(threshold)

API Changed: powerMonitor.querySystemIdleTime is now powerMonitor.getSystemIdleTime

  1. // Removed in Electron 7.0
  2. powerMonitor.querySystemIdleTime(callback)
  3. // Replace with synchronous API
  4. const idleTime = powerMonitor.getSystemIdleTime()

API Changed: webFrame.setIsolatedWorldInfo replaces separate methods

  1. // Removed in Electron 7.0
  2. webFrame.setIsolatedWorldContentSecurityPolicy(worldId, csp)
  3. webFrame.setIsolatedWorldHumanReadableName(worldId, name)
  4. webFrame.setIsolatedWorldSecurityOrigin(worldId, securityOrigin)
  5. // Replace with
  6. webFrame.setIsolatedWorldInfo(
  7. worldId,
  8. {
  9. securityOrigin: 'some_origin',
  10. name: 'human_readable_name',
  11. csp: 'content_security_policy'
  12. })

Removed: marked property on getBlinkMemoryInfo

This property was removed in Chromium 77, and as such is no longer available.

Behavior Changed: webkitdirectory attribute for <input type="file"/> now lists directory contents

The webkitdirectory property on HTML file inputs allows them to select folders. Previous versions of Electron had an incorrect implementation where the event.target.files of the input returned a FileList that returned one File corresponding to the selected folder.

As of Electron 7, that FileList is now list of all files contained within the folder, similarly to Chrome, Firefox, and Edge (link to MDN docs).

As an illustration, take a folder with this structure:

  1. folder
  2. ├── file1
  3. ├── file2
  4. └── file3

In Electron <=6, this would return a FileList with a File object for:

  1. path/to/folder

In Electron 7, this now returns a FileList with a File object for:

  1. /path/to/folder/file3
  2. /path/to/folder/file2
  3. /path/to/folder/file1

Note that webkitdirectory no longer exposes the path to the selected folder. If you require the path to the selected folder rather than the folder contents, see the dialog.showOpenDialog API (link).

API Changed: Callback-based versions of promisified APIs

Electron 5 and Electron 6 introduced Promise-based versions of existing asynchronous APIs and deprecated their older, callback-based counterparts. In Electron 7, all deprecated callback-based APIs are now removed.

These functions now only return Promises:

  • app.getFileIcon() #15742
  • app.dock.show() #16904
  • contentTracing.getCategories() #16583
  • contentTracing.getTraceBufferUsage() #16600
  • contentTracing.startRecording() #16584
  • contentTracing.stopRecording() #16584
  • contents.executeJavaScript() #17312
  • cookies.flushStore() #16464
  • cookies.get() #16464
  • cookies.remove() #16464
  • cookies.set() #16464
  • debugger.sendCommand() #16861
  • dialog.showCertificateTrustDialog() #17181
  • inAppPurchase.getProducts() #17355
  • inAppPurchase.purchaseProduct()#17355
  • netLog.stopLogging() #16862
  • session.clearAuthCache() #17259
  • session.clearCache() #17185
  • session.clearHostResolverCache() #17229
  • session.clearStorageData() #17249
  • session.getBlobData() #17303
  • session.getCacheSize() #17185
  • session.resolveProxy() #17222
  • session.setProxy() #17222
  • shell.openExternal() #16176
  • webContents.loadFile() #15855
  • webContents.loadURL() #15855
  • webContents.hasServiceWorker() #16535
  • webContents.printToPDF() #16795
  • webContents.savePage() #16742
  • webFrame.executeJavaScript() #17312
  • webFrame.executeJavaScriptInIsolatedWorld() #17312
  • webviewTag.executeJavaScript() #17312
  • win.capturePage() #15743

These functions now have two forms, synchronous and Promise-based asynchronous:

  • dialog.showMessageBox()/dialog.showMessageBoxSync() #17298
  • dialog.showOpenDialog()/dialog.showOpenDialogSync() #16973
  • dialog.showSaveDialog()/dialog.showSaveDialogSync() #17054

Planned Breaking API Changes (6.0)

API Changed: win.setMenu(null) is now win.removeMenu()

  1. // Deprecated
  2. win.setMenu(null)
  3. // Replace with
  4. win.removeMenu()

API Changed: electron.screen in the renderer process should be accessed via remote

  1. // Deprecated
  2. require('electron').screen
  3. // Replace with
  4. require('electron').remote.screen

API Changed: require()ing node builtins in sandboxed renderers no longer implicitly loads the remote version

  1. // Deprecated
  2. require('child_process')
  3. // Replace with
  4. require('electron').remote.require('child_process')
  5. // Deprecated
  6. require('fs')
  7. // Replace with
  8. require('electron').remote.require('fs')
  9. // Deprecated
  10. require('os')
  11. // Replace with
  12. require('electron').remote.require('os')
  13. // Deprecated
  14. require('path')
  15. // Replace with
  16. require('electron').remote.require('path')

Deprecated: powerMonitor.querySystemIdleState replaced with powerMonitor.getSystemIdleState

  1. // Deprecated
  2. powerMonitor.querySystemIdleState(threshold, callback)
  3. // Replace with synchronous API
  4. const idleState = powerMonitor.getSystemIdleState(threshold)

Deprecated: powerMonitor.querySystemIdleTime replaced with powerMonitor.getSystemIdleTime

  1. // Deprecated
  2. powerMonitor.querySystemIdleTime(callback)
  3. // Replace with synchronous API
  4. const idleTime = powerMonitor.getSystemIdleTime()

Deprecated: app.enableMixedSandbox() is no longer needed

  1. // Deprecated
  2. app.enableMixedSandbox()

Mixed-sandbox mode is now enabled by default.

Deprecated: Tray.setHighlightMode

Under macOS Catalina our former Tray implementation breaks. Apple’s native substitute doesn’t support changing the highlighting behavior.

  1. // Deprecated
  2. tray.setHighlightMode(mode)
  3. // API will be removed in v7.0 without replacement.

Planned Breaking API Changes (5.0)

Default Changed: nodeIntegration and webviewTag default to false, contextIsolation defaults to true

The following webPreferences option default values are deprecated in favor of the new defaults listed below.

PropertyDeprecated DefaultNew Default
contextIsolationfalsetrue
nodeIntegrationtruefalse
webviewTagnodeIntegration if set else truefalse

E.g. Re-enabling the webviewTag

  1. const w = new BrowserWindow({
  2. webPreferences: {
  3. webviewTag: true
  4. }
  5. })

Behavior Changed: nodeIntegration in child windows opened via nativeWindowOpen

Child windows opened with the nativeWindowOpen option will always have Node.js integration disabled, unless nodeIntegrationInSubFrames is true.

API Changed: Registering privileged schemes must now be done before app ready

Renderer process APIs webFrame.registerURLSchemeAsPrivileged and webFrame.registerURLSchemeAsBypassingCSP as well as browser process API protocol.registerStandardSchemes have been removed. A new API, protocol.registerSchemesAsPrivileged has been added and should be used for registering custom schemes with the required privileges. Custom schemes are required to be registered before app ready.

Deprecated: webFrame.setIsolatedWorld* replaced with webFrame.setIsolatedWorldInfo

  1. // Deprecated
  2. webFrame.setIsolatedWorldContentSecurityPolicy(worldId, csp)
  3. webFrame.setIsolatedWorldHumanReadableName(worldId, name)
  4. webFrame.setIsolatedWorldSecurityOrigin(worldId, securityOrigin)
  5. // Replace with
  6. webFrame.setIsolatedWorldInfo(
  7. worldId,
  8. {
  9. securityOrigin: 'some_origin',
  10. name: 'human_readable_name',
  11. csp: 'content_security_policy'
  12. })

API Changed: webFrame.setSpellCheckProvider now takes an asynchronous callback

The spellCheck callback is now asynchronous, and autoCorrectWord parameter has been removed.

  1. // Deprecated
  2. webFrame.setSpellCheckProvider('en-US', true, {
  3. spellCheck: (text) => {
  4. return !spellchecker.isMisspelled(text)
  5. }
  6. })
  7. // Replace with
  8. webFrame.setSpellCheckProvider('en-US', {
  9. spellCheck: (words, callback) => {
  10. callback(words.filter(text => spellchecker.isMisspelled(text)))
  11. }
  12. })

API Changed: webContents.getZoomLevel and webContents.getZoomFactor are now synchronous

webContents.getZoomLevel and webContents.getZoomFactor no longer take callback parameters, instead directly returning their number values.

  1. // Deprecated
  2. webContents.getZoomLevel((level) => {
  3. console.log(level)
  4. })
  5. // Replace with
  6. const level = webContents.getZoomLevel()
  7. console.log(level)
  1. // Deprecated
  2. webContents.getZoomFactor((factor) => {
  3. console.log(factor)
  4. })
  5. // Replace with
  6. const factor = webContents.getZoomFactor()
  7. console.log(factor)

Planned Breaking API Changes (4.0)

The following list includes the breaking API changes made in Electron 4.0.

app.makeSingleInstance

  1. // Deprecated
  2. app.makeSingleInstance((argv, cwd) => {
  3. /* ... */
  4. })
  5. // Replace with
  6. app.requestSingleInstanceLock()
  7. app.on('second-instance', (event, argv, cwd) => {
  8. /* ... */
  9. })

app.releaseSingleInstance

  1. // Deprecated
  2. app.releaseSingleInstance()
  3. // Replace with
  4. app.releaseSingleInstanceLock()

app.getGPUInfo

  1. app.getGPUInfo('complete')
  2. // Now behaves the same with `basic` on macOS
  3. app.getGPUInfo('basic')

win_delay_load_hook

When building native modules for windows, the win_delay_load_hook variable in the module’s binding.gyp must be true (which is the default). If this hook is not present, then the native module will fail to load on Windows, with an error message like Cannot find module. See the native module guide for more.

Removed: IA32 Linux support

Electron 18 will no longer run on 32-bit Linux systems. See discontinuing support for 32-bit Linux for more information.

Breaking API Changes (3.0)

The following list includes the breaking API changes in Electron 3.0.

app

  1. // Deprecated
  2. app.getAppMemoryInfo()
  3. // Replace with
  4. app.getAppMetrics()
  5. // Deprecated
  6. const metrics = app.getAppMetrics()
  7. const { memory } = metrics[0] // Deprecated property

BrowserWindow

  1. // Deprecated
  2. const optionsA = { webPreferences: { blinkFeatures: '' } }
  3. const windowA = new BrowserWindow(optionsA)
  4. // Replace with
  5. const optionsB = { webPreferences: { enableBlinkFeatures: '' } }
  6. const windowB = new BrowserWindow(optionsB)
  7. // Deprecated
  8. window.on('app-command', (e, cmd) => {
  9. if (cmd === 'media-play_pause') {
  10. // do something
  11. }
  12. })
  13. // Replace with
  14. window.on('app-command', (e, cmd) => {
  15. if (cmd === 'media-play-pause') {
  16. // do something
  17. }
  18. })

clipboard

  1. // Deprecated
  2. clipboard.readRtf()
  3. // Replace with
  4. clipboard.readRTF()
  5. // Deprecated
  6. clipboard.writeRtf()
  7. // Replace with
  8. clipboard.writeRTF()
  9. // Deprecated
  10. clipboard.readHtml()
  11. // Replace with
  12. clipboard.readHTML()
  13. // Deprecated
  14. clipboard.writeHtml()
  15. // Replace with
  16. clipboard.writeHTML()

crashReporter

  1. // Deprecated
  2. crashReporter.start({
  3. companyName: 'Crashly',
  4. submitURL: 'https://crash.server.com',
  5. autoSubmit: true
  6. })
  7. // Replace with
  8. crashReporter.start({
  9. companyName: 'Crashly',
  10. submitURL: 'https://crash.server.com',
  11. uploadToServer: true
  12. })

nativeImage

  1. // Deprecated
  2. nativeImage.createFromBuffer(buffer, 1.0)
  3. // Replace with
  4. nativeImage.createFromBuffer(buffer, {
  5. scaleFactor: 1.0
  6. })

process

  1. // Deprecated
  2. const info = process.getProcessMemoryInfo()

screen

  1. // Deprecated
  2. screen.getMenuBarHeight()
  3. // Replace with
  4. screen.getPrimaryDisplay().workArea

session

  1. // Deprecated
  2. ses.setCertificateVerifyProc((hostname, certificate, callback) => {
  3. callback(true)
  4. })
  5. // Replace with
  6. ses.setCertificateVerifyProc((request, callback) => {
  7. callback(0)
  8. })

Tray

  1. // Deprecated
  2. tray.setHighlightMode(true)
  3. // Replace with
  4. tray.setHighlightMode('on')
  5. // Deprecated
  6. tray.setHighlightMode(false)
  7. // Replace with
  8. tray.setHighlightMode('off')

webContents

  1. // Deprecated
  2. webContents.openDevTools({ detach: true })
  3. // Replace with
  4. webContents.openDevTools({ mode: 'detach' })
  5. // Removed
  6. webContents.setSize(options)
  7. // There is no replacement for this API

webFrame

  1. // Deprecated
  2. webFrame.registerURLSchemeAsSecure('app')
  3. // Replace with
  4. protocol.registerStandardSchemes(['app'], { secure: true })
  5. // Deprecated
  6. webFrame.registerURLSchemeAsPrivileged('app', { secure: true })
  7. // Replace with
  8. protocol.registerStandardSchemes(['app'], { secure: true })

<webview>

  1. // Removed
  2. webview.setAttribute('disableguestresize', '')
  3. // There is no replacement for this API
  4. // Removed
  5. webview.setAttribute('guestinstance', instanceId)
  6. // There is no replacement for this API
  7. // Keyboard listeners no longer work on webview tag
  8. webview.onkeydown = () => { /* handler */ }
  9. webview.onkeyup = () => { /* handler */ }

Node Headers URL

This is the URL specified as disturl in a .npmrc file or as the --dist-url command line flag when building native Node modules.

Deprecated: https://atom.io/download/atom-shell

Replace with: https://atom.io/download/electron

Breaking API Changes (2.0)

The following list includes the breaking API changes made in Electron 2.0.

BrowserWindow

  1. // Deprecated
  2. const optionsA = { titleBarStyle: 'hidden-inset' }
  3. const windowA = new BrowserWindow(optionsA)
  4. // Replace with
  5. const optionsB = { titleBarStyle: 'hiddenInset' }
  6. const windowB = new BrowserWindow(optionsB)

menu

  1. // Removed
  2. menu.popup(browserWindow, 100, 200, 2)
  3. // Replaced with
  4. menu.popup(browserWindow, { x: 100, y: 200, positioningItem: 2 })

nativeImage

  1. // Removed
  2. nativeImage.toPng()
  3. // Replaced with
  4. nativeImage.toPNG()
  5. // Removed
  6. nativeImage.toJpeg()
  7. // Replaced with
  8. nativeImage.toJPEG()

process

  • process.versions.electron and process.version.chrome will be made read-only properties for consistency with the other process.versions properties set by Node.

webContents

  1. // Removed
  2. webContents.setZoomLevelLimits(1, 2)
  3. // Replaced with
  4. webContents.setVisualZoomLevelLimits(1, 2)

webFrame

  1. // Removed
  2. webFrame.setZoomLevelLimits(1, 2)
  3. // Replaced with
  4. webFrame.setVisualZoomLevelLimits(1, 2)

<webview>

  1. // Removed
  2. webview.setZoomLevelLimits(1, 2)
  3. // Replaced with
  4. webview.setVisualZoomLevelLimits(1, 2)

Duplicate ARM Assets

Each Electron release includes two identical ARM builds with slightly different filenames, like electron-v1.7.3-linux-arm.zip and electron-v1.7.3-linux-armv7l.zip. The asset with the v7l prefix was added to clarify to users which ARM version it supports, and to disambiguate it from future armv6l and arm64 assets that may be produced.

The file without the prefix is still being published to avoid breaking any setups that may be consuming it. Starting at 2.0, the unprefixed file will no longer be published.

For details, see 6986 and 7189.