End-to-end typesafe APIs made easy
The client above is not importing any code from the server, only it's type declarations.
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 typesafety & 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-prisma-starter trpc-prisma-starter
Description | URL | Links |
---|---|---|
Next.js starter with Prisma, E2E testing, & ESLint
Quick start with
|
n/a | |
Next.js TodoMVC-example with SSG & Prisma.
Quick start with
|
todomvc.trpc.io | |
Vanilla standalone server & procedure calls with node.js | n/a | |
Express server & procedure calls with node.js. Uses experimental subscriptions. |
n/a |
git clone [email protected]:trpc/trpc.git
cd trpc
yarn
In one terminal, will run preconstruct watch
in parallel which builds all packages/*
on change:
yarn dev
In another terminal, you can for instance navigate to examples/next-prisma-starter
and run yarn dev
& it will update whenever code is changed in the packages.
yarn test --watch
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.
Some things regarding subscriptions is excluded in the coverage as it's an experimental feature
Original 0.x
-version was created by colinhacks and >1.x
was created by KATT.