a toolkit for building end-to-end typesafe data layers
Import type only imports declarations to be used for type annotations and declarations. It always gets fully erased, so thereβs no remnant of it at runtime.
tRPC is a framework for building strongly typed RPC APIs with TypeScript. Alternatively, you can think of it as a way to avoid APIs altogether.
- π§ββοΈΒ Automatic type-safety & autocompletion inferred from your API-paths, their input data, outputs, & errors.
- πΒ Snappy DX. No code generation, run-time bloat, or build pipeline.
- πΒ Light. tRPC has zero deps and a tiny client-side footprint.
- π»Β Easy to add to your existing brownfield project.
- πΒ Batteries included. React-library + Next.js/Express adapters. (But tRPC is not tied to React - reach out if you want to make a Svelte/Vue/... lib)
- π₯Β Simple to use APIs for queries & mutations + experimental subscriptions support.
- πΒ Quite a few examples in the ./examples-folder
- β Β Well-tested & running in production.
tRPC requires TypeScript > 4.1 because of Template Literal Types, but you can get some benefits with autocompletion etc even if you use raw JS.
π See documentation on trpc.io. π
Quick start:
npx create-next-app --example https://github.com/trpc/trpc --example-path examples/next-hello-world my-app| URL | Command | Path | Description |
|---|---|---|---|
| todomvc.trpc.io | yarn example:todomvc |
./examples/next-prisma-todomvc |
TodoMVC-example with SSG & Prisma. Playwright for E2E-testing |
| chat.trpc.io | yarn example:chat |
./examples/next-ssg-chat |
Next.js real-time chat example with SSG & Prisma. Playwright for E2E-testing |
| hello-world.trpc.io | yarn example:hello |
./examples/next-hello-world |
Minimal Next.js example. Playwright for E2E-testing |
| n/a | yarn example:standalone |
./examples/standalone-server |
Standalone tRPC server + node client |
| n/a | yarn example:playground |
./examples/playground |
Express server + node client |
git clone [email protected]:trpc/trpc.git
cd trpc
yarnIn one terminal, will run preconstruct watch in parallel which builds all packages/* on change:
yarn devIn another terminal, you can for instance navigate to examples/next-hello-world and run yarn dev & it will update whenever code is changed in the packages.
cd packages/server
yarn test --watchSome things regarding subscriptions is excluded in the coverage as it's an experimental feature
Testing is currently coalesced in ./packages/server/test - we import the different libs from here, this makes it easier for us to do integration testing + getting test coverage on the whole codebase.
Original 0.x-version was created by colinhacks and >1.x was created by KATT.
Alex Johansson π€ π» |
Colin McDonnell π€ π» |
Pieter Venter π€ π |
Kalle π |
Malte Granderath π |
KristΓ³f PoduszlΓ³ π€ |