Opening a link in the browser in electron platform

I’m trying to do something very simple but yet seems impossible!

I have an ionic-5/capacitor-3 app with iOS/Android/Electron platforms. for electron I use @capacitor-community/electron-4 and everything so far working fine.

Recently, I needed to be able to open a link from the app in the browser, so I imported @capacitor/browser plugin and used Browser.open() which works fine in web, iOS and Android environments but does not work with electron app!

After some research, I learned that for electron app we need to import shell from electron package, and use shell.openExternal(url)

But the problem I’m facing is that, I have to add electron package and “shell” command to my main source which servers all platforms and not able to only add it to electron platform.

Another problem is that, as soon as I add electron package to main package.json, for some reason, ionic tries to build the main source and electron source (in ./electron folder) same time and the fails with tons of errors because ionic is not supposed to build electron app.

Does anybody have any solution for opening a link in browser that works on all environments, including electron?

1 Like

did you find the solution?

I did not find any solution so I dropped the electron app and instead created a PWA app that can be installed from the web on any platform and works great. much lighter and faster than Electron!