Search code examples
javascriptreactjselectronprotocols

How to register an protocol/deep links to my Electron App?


Error launching app: "Unable to find Electron app at..."

I'm using electron-react-boilerplate and I'm not able to create a handler that opens my electron app in development mode.

I've read the Deep Links and Protocol documentation and I still couldn't get it to work!

Following the Deep Links documentation I was able to open the app after it was packaged into an .exe, but I can't debug and catch this event and work on the front-end.

In development mode this error appears whenever I access the handler:

Error screenshot


Solution

  • I managed to solve it by adding on main.js:

    if (!app.isDefaultProtocolClient('electron-handler')) {  
      app.setAsDefaultProtocolClient('electron-handler')
    }
    

    and this on package.json:

    "build": {
      ...
      "protocols": {
        "name": "my electron handler",
        "schemes": [
          "electron-handler"
        ]
      },
    }