Detect if it's Electron runtime
Posted on June 28, 2019
Detect if it's Electron runtime
When I need to share the same codebase between a WebApp and an ElectronApp, I use the following condition to run specific code based on the host environment:
if (window.process && window.process.type && window.process.type === 'renderer') {
// run code for Electron only
}
Not beautiful but it works!