Occasionally, you'll need to make Capacitor updates to your Electron app, including new ways of interfacing with Capacitor inside of your Electron codebase.
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
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.
Recommended changes:
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.gitignore file inside electron folder with this contentelectron-is-dev dependency to ^1.1.0 as on the templateRecommended changes:
index.js file inside electron folder to call configCapacitor(mainWindow);
like this to be able to configure the userAgent from
this featureMandatory change:
injectCapacitor was deprecated on 1.1.0 and has been removed on 2.0.0, if still using it you have to update
index.js to remove the usage.
See exampleRecommended changes:
splashScreen.init(false); in
index.js to splashScreen.init();.