Using Prisma and tRPC with Electron

Last updated on

When I built my Electron app, I created an architecture that uses React, tRPC, and Prisma with SQLite. This is a productive desktop app stack. If you want to try it, I extracted it into a generic template repository here: https://github.com/awohletz/electron-prisma-trpc-example.

If you have any issues or questions, contact me or log an issue on Github.

Prisma was a bit tricky to figure out how to use in Electron. It’s not quite its intended use-case. But it does work. And it enables migrations, TypeScript interfaces, schema management, and so on in a desktop app.

I prefer Prisma to the other TypeScript ORMs in the ecosystem, because it’s not object-oriented. It’s more data-oriented. For example, queries are JSON objects, not some chaining API. Results are JSON objects that conform to TS interfaces, not instances of classes. That fits my functional-lite programming style.

One downside is that the Prisma binaries increase the Electron app bundle size. The app needs those binaries to run Prisma migrate at runtime.