neel
neel

Reputation: 827

How to differentiate between the main process and renderer process in Electron (atom shell)?

How to differentiate between the main process and renderer process in Electron (atom shell)?

Upvotes: 19

Views: 6071

Answers (3)

Marshal
Marshal

Reputation: 4880

Not sure if the high rated answer had been modified mistakenly. The correct logic should be:

const isRenderer = typeof process === 'undefined' || !process || process.type === 'renderer'

Upvotes: -1

Ana Betts
Ana Betts

Reputation: 74692

var isRenderer = (process && process.type === 'renderer')

Upvotes: 29

Olim Saidov
Olim Saidov

Reputation: 2844

This library might help you. It has simple API:

var isRenderer = require('is-electron-renderer')
console.log(isRenderer); //true or false

Upvotes: 0

Related Questions