ipc-handler

star 8

Create IPC handlers for main-renderer communication

TengraStudio By TengraStudio schedule Updated 1/22/2026

name: IPC Handler description: Create IPC handlers for main-renderer communication

IPC Handler Skill

Location

src/main/ipc/{domain}.ts

Handler Template

import { ipcMain } from 'electron'
import { appLogger } from '@main/logging/logger'
import { ServiceResponse } from '@shared/types'

export function register{Domain}Handlers(service: {Service}Service): void {
    ipcMain.handle('{domain}:{action}', async (_event, args): Promise<ServiceResponse<ResultType>> => {
        try {
            const result = await service.doSomething(args)
            return { success: true, data: result }
        } catch (error) {
            appLogger.error('IPC', '{domain}:{action} failed', error as Error)
            return { success: false, error: (error as Error).message }
        }
    })
}

Preload Exposure

Add to src/main/preload.ts:

{domain}: {
    {action}: (args: ArgsType) => ipcRenderer.invoke('{domain}:{action}', args)
}

Renderer Usage

const result = await window.api.{domain}.{action}(args)
if (result.success) {
    // use result.data
}
Install via CLI
npx skills add https://github.com/TengraStudio/tengra --skill ipc-handler
Repository Details
star Stars 8
call_split Forks 4
navigation Branch main
article Path SKILL.md
More from Creator
TengraStudio
TengraStudio Explore all skills →