Installation
Prerequisites
Section titled “Prerequisites”- Node.js >= 18
- Electron >= 22
- tRPC v11 (
@trpc/serverand@trpc/client)
Install the Package
Section titled “Install the Package”npm install electron-messageport-trpc @trpc/server@^11 @trpc/client@^11pnpm add electron-messageport-trpc @trpc/server@^11 @trpc/client@^11yarn add electron-messageport-trpc @trpc/server@^11 @trpc/client@^11Package Exports
Section titled “Package Exports”The library ships with four entry points, each targeting a specific Electron process:
| Import path | Process | Purpose |
|---|---|---|
electron-messageport-trpc/main | Main | Port broker and request handler |
electron-messageport-trpc/preload | Preload | Expose port receiver to renderer |
electron-messageport-trpc/renderer | Renderer | tRPC link and port getter |
electron-messageport-trpc/utility | Utility | Attach a tRPC handler to parentPort in a utility process |
TypeScript Setup
Section titled “TypeScript Setup”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:
import { initTRPC } from '@trpc/server';
const t = initTRPC.create();export const appRouter = t.router({ // ... your procedures});
export type AppRouter = typeof appRouter;Next Steps
Section titled “Next Steps”Head to the Quick Start guide to wire everything together.