DEV Community

Nutchanon Ninyawee
Nutchanon Ninyawee

Posted on

Answer: How to pass parameters from main process to render processes in Electron

Using query string along with win.loadFile(),

// main process or renderer process 1
data = {"age": 12, "healthy": true}

let win = new BrowserWindow({
        webPreferences: {
          nodeIntegration: true
        }
      });

win.loadFile("public/print.html", {query: {"data": JSON.stringify(data)}});
// renderer process 2
const querystring = require('querystring');
let query = querystring.parse(global.location.search);
let data =

Top comments (0)