4

In my app, I need to on full load, detect if is Electron, then fire a custom event. How to achieve it? Thanks in advance.

  • Possible duplicate of [How to set electron UserAgent](http://stackoverflow.com/questions/35672602/how-to-set-electron-useragent) – Sandy Gifford Apr 21 '17 at 18:48

2 Answers2

9

I prefer this

// check if app is running inside the electron env or browser
var userAgent = navigator.userAgent.toLowerCase();
if (userAgent.indexOf(' electron/') == -1) {
  // its not electron
}
www.amitpatil.me
  • 3,001
  • 5
  • 43
  • 61
0
if(process.versions.electron != 'undefined' && process.versions.electron != null){
    //Custom event
}

I think is the most standard way of doing this.

Kyle Becker
  • 1,360
  • 12
  • 20