Lately I found myself developing an ElectronJS app. I am building some kind of a bridge between software clients and project management tools like Jira, GitLab, Trello, etc.

Here are a few things you should know if you are just starting with ElectronJS:

  • Electron runs two types of processes: one main process that runs whatever you defined as being the main entry point in the package.json file, and n number of renderer processes; where n is the number of browser windows your app opens.
  • The main process role is to manage your browser windows: to create or destroy, and to help them communicate.
  • Render Processes a.k.a BrowserWindows cannot communicate directly between each other. Every communication goes through the main process using events and listeners.
  • You can share global variables between windows, but those are only defined in the main process, so it doesn’t count as actual communication between pages.
  • Be careful how you setup your listeners. I made the mistake of setting a listener when a certain window was being created. Guess what: it happened that I was creating that window more than a few times and with each window creating a new listener in the main process, causing the app to execute the same thing multiple times. Either cleanup after yourself (remove listeners on window’s close event) or make sure you only set it up once.