Introduction | Electron IPC Bridge

1 min read Original article ↗

Electron IPC Bridge is a type-safe, class-based IPC framework for Electron applications.

Inspired by NestJS, this library allows you to structure your Electron Main Process logic using Controllers and Decorators. It includes a Vite plugin that automatically generates TypeScript definitions for your Renderer process, ensuring your renderer and main process types are always in sync without manual duplication.

The library bridges your main and renderer processes using shared types generated at build time.

import { IpcController, IpcHandle } from "@electron-ipc-bridge/core";

@IpcController("users")
export class UserController {
@IpcHandle()
async getUser(id: string) {
// Return standard objects, promises, or throw errors
return { id, name: "Alice" };
}
}

After building my own non-trivial Electron app, I found that too much time was spent updating the preload script and renderer types, defining constants for channel names, and maintaining shared configurations for API types. I originally built a much simpler version of this library for my own use, but I thought genericising and publishing it might help others who take a class-based approach to their application's backend.