Skip to main content


MessageChannelMain is the main-process-side equivalent of the DOM MessageChannel object. Its singular function is to create a pair of connected MessagePortMain objects.

See the Channel Messaging API documentation for more information on using channel messaging.

Class: MessageChannelMain#

Channel interface for channel messaging in the main process.

Process: Main


// Main processconst { MessageChannelMain } = require('electron')const { port1, port2 } = new MessageChannelMain()w.webContents.postMessage('port', null, [port2])port1.postMessage({ some: 'message' })
// Renderer processconst { ipcRenderer } = require('electron')ipcRenderer.on('port', (e) => {  // e.ports is a list of ports sent along with this message  e.ports[0].on('message', (messageEvent) => {    console.log(  })})

Instance Properties#


A MessagePortMain property.


A MessagePortMain property.