With Electron, node.js does not act like a web server with routes such as in a typical web application scenario. Instead of sending requests for routes, you will create a one-page application using a javascript framework such as Angular, React, Knockout, etc. At this point, you no longer need to handle routing. You bind your "Send" event to the client to the javascript function directly on the page and process the input from it.
You can do everything from the javascript context of the page, which you can do from the context of the main node.js process. For example, if you need to access the file system from your page, you must use the Remote module to access node.js.
For instance:
// Gain access to the node.js file system api function useNodeApi() { const remote = require('electron').remote; const fs = remote.require('fs'); fs.writeFile('test.txt', 'Hello, I was written by the renderer process!'); }
I rarely came across a situation where I needed to go to the main process in order to accomplish something. After starting BrowserWindow, everything you ever need to do can be done from the rendering process. This pretty much eliminates the need to do things like send form messages via http.
source share