Running code inside renderer process


#1

Where is the render process in an Electron app? I understand the the difference between the main and render processes, but if I want code to specifically run in the render process, where can I write it? The related documentation returns a 404: http://electron.atom.io/docs/glossary#renderer-process


#2

The documentation needs to be fixed, but this is visible (just not explained) in the Quick Start. Renderer processes run any code loaded by a BrowserWindow. In the case of the Quick Start, that’s an HTML page with some embedded <script> tags, but imagine that HTML page linking out to another JS document (which we’ll call app.js). The main process is meant to handle the dirty work of being a desktop application. The meat of your app should be in a file like app.js, and when a BrowserWindow loads an index.html that asks for app.js, the renderer process will load and run the app.


#3

Of course, thank you. For some reason I was looking for something like an app.on('render', () => {}) or similar. I threw my desktopCapturer code into my main <App/> component and it worked as expected.


#4

It’s much more straightforward than that. Of course, renderer processes being tied to windows means that you have to be sure to pass any batons off if the window is closed or replaced.