mit einem Klick
electron-ipc
// Safe Electron IPC patterns for renderer-main communication with preload bridges, channel design, replies, and serialization limits.
// Safe Electron IPC patterns for renderer-main communication with preload bridges, channel design, replies, and serialization limits.
rTorrent XML-RPC command reference focused on remote control, multicall patterns, load methods, and the torrent commands used by Electorrent.
Deluge Web JSON-RPC and core RPC reference covering session login, web methods, and commonly used core torrent operations.
qBittorrent WebUI API reference covering authentication, sync, transfer, torrent, RSS, and search endpoints for qBittorrent 5.0+.
Write code edits quickly without performing testing or validation
Synology Download Station Web API reference covering API discovery, authentication, request format, common errors, and Download Station task operations.
Transmission RPC reference covering JSON-RPC 2.0 transport, session token handling, torrent methods, session methods, and protocol versioning.
| name | electron-ipc |
| description | Safe Electron IPC patterns for renderer-main communication with preload bridges, channel design, replies, and serialization limits. |
Use this skill when you need to design or implement communication between Electron's main and renderer processes.
ipcMain and ipcRenderer.contextBridge
instead of exposing raw Electron modules to the renderer.openFile() or
setTitle(title).ipcRenderer.send, ipcRenderer.invoke, or ipcRenderer.on
directly to renderer code.dialog:openFile for readability.| Need | Renderer API | Main API | Notes |
|---|---|---|---|
| Fire-and-forget renderer -> main | ipcRenderer.send | ipcMain.on | Good for commands with no result |
| Request/response renderer -> main | ipcRenderer.invoke | ipcMain.handle | Preferred two-way pattern |
| Push main -> renderer | preload listener wrapper | webContents.send | Main must target a specific window/webContents |
| Renderer -> renderer | relay through main or MessagePort | main as broker if needed | No direct IPC channel between renderers |
Use this when the renderer triggers a main-process action and does not need a result.
ipcMain.on('set-title', (event, title) => {
const win = BrowserWindow.fromWebContents(event.sender)
win?.setTitle(title)
})
contextBridge.exposeInMainWorld('electronAPI', {
setTitle: (title) => ipcRenderer.send('set-title', title)
})
window.electronAPI.setTitle('New title')
Use this when the renderer needs a result from the main process. Prefer this over older reply patterns.
ipcMain.handle('dialog:openFile', async () => {
const { canceled, filePaths } = await dialog.showOpenDialog()
return canceled ? undefined : filePaths[0]
})
contextBridge.exposeInMainWorld('electronAPI', {
openFile: () => ipcRenderer.invoke('dialog:openFile')
})
const filePath = await window.electronAPI.openFile()
invoke/handle is the preferred async request-response model.ipcMain.handle are serialized; the renderer does not receive the
full original error object.Use this when the main process needs to push updates into a specific window.
mainWindow.webContents.send('update-counter', 1)
contextBridge.exposeInMainWorld('electronAPI', {
onUpdateCounter: (callback) => {
ipcRenderer.on('update-counter', (_event, value) => callback(value))
}
})
window.electronAPI.onUpdateCounter((value) => {
// update UI
})
There is no invoke equivalent from main to renderer. If the renderer needs to
reply, send a new message back to the main process on a separate channel.
Avoid these unless you have a strong compatibility reason:
ipcRenderer.send plus event.reply for two-way communication:
works, but forces manual reply-channel bookkeeping.ipcRenderer.sendSync: blocks the renderer and hurts responsiveness.ipcRenderer methods over contextBridge.Electron IPC uses the Structured Clone Algorithm.
BrowserWindow or
WebContents, and Node/Electron objects backed by native C++ classes.Pass serializable data, not live framework objects.
send + oninvoke + handlewebContents.sendMessagePort