# hadron-ipc

> Simplified IPC for electron apps.

Latest version **3.6.2** (published 2026-07-15) · SSPL license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install hadron-ipc
pnpm add hadron-ipc
yarn add hadron-ipc
bun add hadron-ipc
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 3.6.2 |
| Published | 2026-07-15 |
| First published | 2016-04-14 |
| Weekly downloads | 0 |
| License | SSPL |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 58.7 KB |
| Known vulnerabilities | 0 (+8 in 1 direct dependencies) |
| Install scripts | no |
| Author | MongoDB Inc |
| Maintainers | alexander_schroll, satyasinha, jeff-allen-mongo, jonathan.balsano, mongodb-build, kristina.stefano, jarjee, shaketbaby, devtoolsbot, mongo-j, dariakp, nbbeeken, dbx-node, devtools-npm-user, mcasimir_mdb, imlucas |

## Links

- npm: https://www.npmjs.com/package/hadron-ipc
- Repository: https://github.com/mongodb-js/compass
- Issues: https://jira.mongodb.org/projects/COMPASS/issues
- npm.io page: https://npm.io/package/hadron-ipc

## Dependencies (3)

- [debug](https://npm.io/package/debug.md) ^4.3.4
- [electron](https://npm.io/package/electron.md) ^41.1.1
- [is-electron-renderer](https://npm.io/package/is-electron-renderer.md) ^2.0.1

## Recent versions

- 3.6.2 (latest) — 2026-07-15
- 0.0.0-next-e20763a4901d6f8dbea880c350b1e78d14afec4a (next) — 2025-01-21
- 0.0.0-experimental-1c53312ce4905234885618d41ae95fde9c21aa18 (experimental) — 2022-09-26
- 3.6.1 — 2026-07-01
- 3.6.0 — 2026-06-17
- 3.5.32 — 2026-04-20
- 3.5.31 — 2026-04-17
- 3.5.30 — 2026-03-26
- 3.5.29 — 2026-03-11
- 3.5.28 — 2026-02-26
- 3.5.27 — 2026-02-25
- 3.5.26 — 2026-01-23
- 3.5.25 — 2026-01-13
- 3.5.24 — 2026-01-02
- 3.5.23 — 2025-12-16
- … 543 more at https://npm.io/package/hadron-ipc/versions

## README

# hadron-ipc [![npm][npm_img]][npm_url]

Simplified wrapper around Electron's IPC events.

# Usage

```javascript
process.env.DEBUG = 'hadron-*';

const ipc = require('hadron-ipc');
const AppRegistry = require('@mongodb-js/compass-app-registry');

const globalAppRegistry = new AppRegistry();

// called from a renderer process:
ipc.call('compass:loading:change-status', { status: 'loading preferences' });

// responded to in the main process:
ipc.respondTo('app:loading:change-status', (evt, meta) => {
  // main process then broadcasts to its renderer processes:
  ipc.broadcast('app:loading:change-status', meta);
});

// renderer process deals with information when received
ipc.on('app:loading:change-status', (evt, meta) => {
  globalAppRegistry.emit('app:loading:change-status', meta);
});
```

## API - from Main Process

Communication from the main process to a renderer process.

### ipc.respondTo(methodName, handler)

Respond to an event sent from a renderer process. `handler` keeps track of
`BrowserWindow` instance and any of the `args`.

```js
const ipc = require('hadron-ipc');

const onFindInPage = (sender, searchTerm, opt) => {
  if (!_window) return;

  opt = opt || {};
  _window.webContents.findInPage(searchTerm, opt);
};

ipc.respondTo('app:find-in-page', onFindInPage);
```

You can also use `broadcast` as part of the response:

```js
const ipc = require('hadron-ipc');

ipc.respondTo('app:loading:change-status', (evt, meta) => {
  ipc.broadcast('app:loading:change-status', meta);
});
```

### ipc.broadcast(methodName, [...args])

Broadcast an event to renderer process(es).

For example, here is a broadcast from a Menu Item:

```js
const ipc = require('hadron-ipc');

function viewSubMenu() {
  return {
    label: '&View',
      {
        label: '&Reload Data',
        accelerator: 'CmdOrCtrl+R',
        click: function() {
          ipc.broadcast('app:refresh-data'); // renderer processes will be
listening to this event
        }
      }
    ]
  };
}
```

### ipc.broadcastFocused(methodName, [...args])

Broadcast to renderer process(es) only if the current window is focused.

```js
ipc.broadcastFocused('app:disconnect');
```

### ipc.remove(channel, listener)

Remove a listener from the main process' ipc.

```js
const ipc = require('hadron-ipc');

const onFindInPage = (sender, searchTerm, opt) => {
  if (!_window) return;

  opt = opt || {};
  _window.webContents.findInPage(searchTerm, opt);
};

ipc.remove('app:stop-find-in-page', onStopFindInPage);
```

## API - from Renderer process

Communication from a renderer proces to the main process. All of the
[ipcRenderer][ipc-renderer] events are kept as
is, `ipc.call` is added as an additional method.

### ipc.call(methodName, [...args])

Call the main process under the provided `methodName`. Under the hood `args`
are serialised as JSON.

```js
const ipc = require('hadron-ipc');

const args = {
  query: {
    filter: {},
    project: { field: 1 }
  }
};
ipc.call('app:open-export', args, (res) = {
  console.log('callback from renderer process', res)
});
```

### ipc.on(methodName, handler)

From Electron's `ipcRenderer` API. Useful for when replying to Main process'
`ipc.broadcast` events.

```js
const ipc = require('hadron-ipc');

ipc.on('app:refresh-data', () =>
  // do something
);
```

# Install

```shell
npm install hadron-ipc
```

# Related Content

- [Electron's ipcMain][ipc-main]
- [Electron's ipcRenderer][ipc-renderer]
- [Hadron App][hadron-app]
- [Compass App Registry][compass-app-registry]

[npm_img]: https://img.shields.io/npm/v/hadron-ipc.svg
[npm_url]: https://npmjs.org/package/hadron-ipc
[ipc-renderer]: https://electronjs.org/docs/api/ipc-renderer
[ipc-main]: https://electronjs.org/docs/api/ipc-mai://electronjs.org/docs/api/ipc-main
[hadron-app]: https://github.com/mongodb-js/compass/tree/main/packages/hadron-app
[compass-app-registry]: https://github.com/mongodb-js/compass/tree/main/packages/compass-app-registry

---
_Source: https://npm.io/package/hadron-ipc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
