Updating Your Capacitor Electron Project

Occasionally, you'll need to make Capacitor updates to your Electron app, including new ways of interfacing with Capacitor inside of your Electron codebase.

Updating Capacitor Electron Library

To update the version of @capacitor/electron used in your app, just npm install latest version from inside electron folder:

cd electron
npm install @capacitor/electron@latest

Updating Electron Project

To update the base structure of your Electron project, view the electron-template project in the Capacitor repo, under the tag corresponding to the latest stable release of Capacitor. The core project is kept simple on purpose: it shouldn't take much time to see what is different from the core project and your project.

From 1.0.0 to 1.1.0

Recommended changes:

  • Update index.js to not use injectCapacitor function as it's now deprecated and will be removed on 2.0.0. It also fixes problems when using electron 5. See example
  • Create a .gitignore file inside electron folder with this content
  • Update electron-is-dev dependency to ^1.1.0 as on the template

From <= 1.3.0 to 1.4.0

Recommended changes:

  • Update electron to ^7.0.0
  • Update index.js file inside electron folder to call configCapacitor(mainWindow); like this to be able to configure the userAgent from this feature


Back Next