Skip to content

Installation

  • Node.js >= 18
  • Electron >= 22
  • tRPC v11 (@trpc/server and @trpc/client)
Terminal window
npm install electron-messageport-trpc @trpc/server@^11 @trpc/client@^11

The library ships with four entry points, each targeting a specific Electron process:

Import pathProcessPurpose
electron-messageport-trpc/mainMainPort broker and request handler
electron-messageport-trpc/preloadPreloadExpose port receiver to renderer
electron-messageport-trpc/rendererRenderertRPC link and port getter
electron-messageport-trpc/utilityUtilityAttach a tRPC handler to parentPort in a utility process

The package includes TypeScript declarations. No additional @types packages are needed.

For full type inference on your tRPC router, export the router type from your main process code and import it in your renderer:

main/router.ts
import { initTRPC } from '@trpc/server';
const t = initTRPC.create();
export const appRouter = t.router({
// ... your procedures
});
export type AppRouter = typeof appRouter;

Head to the Quick Start guide to wire everything together.