electron-api
Installation
SKILL.md
Adding Electron APIs
Electron APIs allow the frontend to call Electron main process functionality directly via IPC.
Four Files to Edit
frontend/types/custom.d.ts- TypeScriptElectronApitypeemain/preload.ts- Expose method viacontextBridgeemain/emain-ipc.ts- Implement IPC handlerfrontend/preview/preview-electron-api.ts- Add a no-op stub to keep thepreviewElectronApiobject in sync with theElectronApitype
Three Communication Patterns
- Sync -
ipcRenderer.sendSync()+ipcMain.on()+event.returnValue = ... - Async -
ipcRenderer.invoke()+ipcMain.handle() - Fire-and-forget -
ipcRenderer.send()+ipcMain.on()