Different ways to communicate between main and renderer process

No BS. Code says it all.

Main process

'use strict'

var electron = require('electron');  
var {app, BrowserWindow, ipcMain} = electron;  
var mainWindow = null;

app.on('ready', () => {  
    mainWindow = new BrowserWindow({
        width: 200,
        height: 200
    });
    mainWindow.loadURL(`file://${__dirname}/index.html`);
});

// Listen for async message from renderer process
ipcMain.on('async', (event, arg) => {  
    // Print 1
    console.log(arg);
    // Reply on async message from renderer process
    event.sender.send('async-reply', 2);
});

// Listen

Read More