node.jselectronnwjs

electron url scheme "open-url" event


I did the following in my index.js;

electron.remote.app.on("open-url", function(event, url) {
  console.log("Open URL: " + url);
});

This gets triggered in Mac OS, but not in Windows. Is there another event or a different way to do it in windows?


Solution

  • This is a mac-only feature. The closest alternative is app.makeSingleInstance(callback).

    You can arrange for your app to be launched with the url as argument: myApp my-scheme://stuff

    Then callback is called with the url in whichever app process was launched first.