Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Inter‑process Commun | Electron.js Desktop App Development l | BraveProgrammer
  1. Courses
  2. /
  3. Electron.js Desktop App Development

Lesson 28 of 28

·javascript

Inter‑process Communication (IPC)

12 mins

Course progress100%

What you'll learn

Keep these ideas in mind as you work through the lesson.

4 points
  • `ipcRenderer.invoke` → `ipcMain.handle` returns a **Promise** (clean async API).
  • `ipcRenderer.send` → `ipcMain.on` is fire‑and‑forget (no response).
  • Never expose the raw `ipcRenderer` object; use a **preload bridge** with a whitelisted API.
  • All messages are serialized; you can pass JSON‑compatible data only.

Inter‑process Communication (IPC)

Electron ships two IPC modules:

  • ipcMain – used in the main process.
  • ipcRenderer – used in a renderer (via the preload bridge).

Basic request/response pattern

preload/bridge.js

const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('api', {
  getAppVersion: () => ipcRenderer.invoke('app:getVersion')
});

main.js

const { ipcMain, app } = require('electron');
ipcMain.handle('app:getVersion', () => app.getVersion());

renderer.js (runs in the page)

document.getElementById('ver').innerText = window.api.getAppVersion();

Sending a fire‑and‑forget message

// renderer
window.api.send('log', 'User clicked button');
// main
ipcMain.on('log', (e, msg) => console.log('[Renderer]', msg));

Use invoke/handle for request‑response (Promise‑based) and send/on for one‑way messages.

Make it stickPractice what you've learned1 quiz · 5 practical tests · Optional activities from Electron.js Desktop App DevelopmentBrowse activities
Previous lessonMenus, Application Menu & Tray IconsCourse completeBack to the curriculumBack to Electron.js Desktop App Development curriculum