Open URL with Electron in non-default Browser

Viewed 1333

I am using Electron to try and open a URL. I know I can do something like

const { shell } = require('electron')

shell.openExternal('https://github.com')

to open the URL in the default browser.

Is there any way to do this in the non-default browser? For example, if I want to open a link to the Edge Store, but my default browser is Chrome, can I do something like

const { shell } = require('electron')

shell.openExternal('microsoft-edge:https://github.com')
1 Answers

You're not going to be able to do that with just default shell, because as far as I know it relies entirely on user system defaults, but there are existing npm packages like open that will give you this functionality, with something like:

await open('microsoft-edge:https://github.com');

Their documentation will walk you through how to get this working.

Related