{"id":14006979,"url":"https://github.com/jsonnull/electron-trpc","last_synced_at":"2025-05-15T04:06:32.177Z","repository":{"id":50288441,"uuid":"518305948","full_name":"jsonnull/electron-trpc","owner":"jsonnull","description":"Build type-safe Electron inter-process communication using tRPC","archived":false,"fork":false,"pushed_at":"2024-12-07T22:36:34.000Z","size":680,"stargazers_count":324,"open_issues_count":9,"forks_count":33,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-09T01:05:08.058Z","etag":null,"topics":["electron","hacktoberfest","ipc","trpc","typescript"],"latest_commit_sha":null,"homepage":"https://electron-trpc.dev/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsonnull.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-27T04:15:59.000Z","updated_at":"2025-05-05T18:03:44.000Z","dependencies_parsed_at":"2024-04-21T05:53:26.420Z","dependency_job_id":"0150ee61-4db1-4392-9fda-42e0041c30ad","html_url":"https://github.com/jsonnull/electron-trpc","commit_stats":{"total_commits":143,"total_committers":9,"mean_commits":15.88888888888889,"dds":"0.46853146853146854","last_synced_commit":"5acadea0f0b790ffc7712007a35be581e0464bd6"},"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsonnull%2Felectron-trpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsonnull%2Felectron-trpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsonnull%2Felectron-trpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsonnull%2Felectron-trpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsonnull","download_url":"https://codeload.github.com/jsonnull/electron-trpc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254270646,"owners_count":22042859,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["electron","hacktoberfest","ipc","trpc","typescript"],"created_at":"2024-08-10T10:01:44.590Z","updated_at":"2025-05-15T04:06:27.135Z","avatar_url":"https://github.com/jsonnull.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","typescript"],"sub_categories":[],"readme":"# electron-trpc\n\n\u003cp\u003e\n  \u003ca href=\"https://www.npmjs.com/package/electron-trpc\"\u003e\n    \u003cimg alt=\"NPM\" src=\"https://img.shields.io/npm/v/electron-trpc\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/jsonnull/electron-trpc\"\u003e \n  \u003cimg src=\"https://codecov.io/gh/jsonnull/electron-trpc/branch/main/graph/badge.svg?token=DU33O0D9LZ\"/\u003e \n  \u003c/a\u003e\n  \u003cspan\u003e\n    \u003cimg alt=\"MIT\" src=\"https://img.shields.io/npm/l/electron-trpc\"/\u003e\n  \u003c/span\u003e\n\u003c/p\u003e\n\n\u003cp\u003e\u003c/p\u003e\n\n**Build IPC for Electron with tRPC**\n\n- Expose APIs from Electron's main process to one or more render processes.\n- Build fully type-safe IPC.\n- Secure alternative to opening servers on localhost.\n- Full support for queries, mutations, and subscriptions.\n\n## Installation\n\n```sh\n# Using pnpm\npnpm add electron-trpc\n\n# Using yarn\nyarn add electron-trpc\n\n# Using npm\nnpm install --save electron-trpc\n```\n\n## Basic Setup\n\n1. Add your tRPC router to the Electron main process using `createIPCHandler`:\n\n   ```ts\n   import { app } from 'electron';\n   import { createIPCHandler } from 'electron-trpc/main';\n   import { router } from './api';\n\n   app.on('ready', () =\u003e {\n     const win = new BrowserWindow({\n       webPreferences: {\n         // Replace this path with the path to your preload file (see next step)\n         preload: 'path/to/preload.js',\n       },\n     });\n\n     createIPCHandler({ router, windows: [win] });\n   });\n   ```\n\n2. Expose the IPC to the render process from the [preload file](https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts):\n\n   ```ts\n   import { exposeElectronTRPC } from 'electron-trpc/main';\n\n   process.once('loaded', async () =\u003e {\n     exposeElectronTRPC();\n   });\n   ```\n\n   \u003e Note: `electron-trpc` depends on `contextIsolation` being enabled, which is the default.\n\n3. When creating the client in the render process, use the `ipcLink` (instead of the HTTP or batch HTTP links):\n\n   ```ts\n   import { createTRPCProxyClient } from '@trpc/client';\n   import { ipcLink } from 'electron-trpc/renderer';\n\n   export const client = createTRPCProxyClient({\n     links: [ipcLink()],\n   });\n   ```\n\n4. Now you can use the client in your render process as you normally would (e.g. using `@trpc/react`).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsonnull%2Felectron-trpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsonnull%2Felectron-trpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsonnull%2Felectron-trpc/lists"}