EGE
EGE

Reputation: 69

How to open my electron program when a link (like myprogram://a/a) is clicked in a web browser

I want to transfer information from my website to my electron program by using a link that has some data in it (like myprogram://data). But can't seem to find any info on the internet about this. Any help would be gladly appreciated.

Thanks!

Upvotes: 2

Views: 122

Answers (1)

aabuhijleh
aabuhijleh

Reputation: 2464

You need to register your app as a protocol handler using app.setAsDefaultProtocolClient

app.setAsDefaultProtocolClient("myprogram")

On Windows, when the "myprogram://data" link is clicked, a new instance of your application will be launched and the arguments will be included in process.argv

Use app.requestSingleInstanceLock if you don't want multiple instances of your app to be running

On macOS, you can get the arguments using the open-url event

Upvotes: 1

Related Questions