Thanks to visit codestin.com
Credit goes to github.com

Skip to content
forked from trpc/trpc

πŸ§™β€β™‚οΈ TypeScript toolkit for building end-to-end typesafe APIs

License

Notifications You must be signed in to change notification settings

lib-design/trpc

Β 
Β 

Repository files navigation

tRPC

a toolkit for building end-to-end typesafe data layers

codecov

Server/client example 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.

Intro

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.


Usage

πŸ‘‰ 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

Example apps

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

Development workflow

git clone [email protected]:trpc/trpc.git
cd trpc
yarn

Hacking around with it

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-hello-world and run yarn dev & it will update whenever code is changed in the packages.

Testing

cd packages/server
yarn test --watch

codecov

Some 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.

Contributors ✨

Original 0.x-version was created by colinhacks and >1.x was created by KATT.


Alex Johansson

πŸ€” πŸ’» ⚠️ πŸ“– πŸ’‘ 🚧

Colin McDonnell

πŸ€” πŸ’» ⚠️ πŸ“–

Pieter Venter

πŸ€” πŸ‘€

Powered by Vercel

About

πŸ§™β€β™‚οΈ TypeScript toolkit for building end-to-end typesafe APIs

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 91.7%
  • JavaScript 6.3%
  • CSS 2.0%