CodeVetter
← All unpacks
CodeVetter · Repo Unpack evidence

trpc/trpc

Scanned commit 8b649ad874 dated 2026-09-17 — last upstream commit. Generated by codevetter 1.12.0 on 2026-09-22.

github.com/trpc/trpc ↗ · 1555 files · 5.3 MB

tRPC Move fast and break nothing. End-to-end typesafe APIs made easy.

Deep analysis by cli:grok via the grok CLI on 2026-09-22 (403s) — every claim below links to its cited source files.

Overview

tRPC 11.19.0 (this checkout of github.com/trpc/trpc) is a TypeScript monorepo for end-to-end typesafe RPCs without schemas or code generation. Application authors define procedures once with initTRPC; clients call them through a typed Proxy that never imports server runtime code, only its types. @trpc/server is transport-agnostic and ships adapters for Fetch, Node, Express, Fastify, Next.js, AWS Lambda, a standalone HTTP server, and WebSockets, while @trpc/client, @trpc/react-query, and @trpc/tanstack-react-query consume the same router type. The repo also contains runnable examples (Next/Prisma, a Drizzle SSE chat, Cloudflare Workers, Nuxt, Lambdas), an alpha OpenAPI generator, a jscodeshift upgrade CLI, and the Docusaurus docs site in www/.

System map

The publishable libraries live under packages/ and are wired as a pnpm workspace (packages/*, examples/*, www) driven by Turborepo. @trpc/server is the runtime and type core; adapters are thin wrappers around resolveResponse or, for WebSockets, applyWSSHandler. The client is a link chain terminated by HTTP or WS. There is no database inside the library — persistence shows up only in examples (Prisma, Drizzle). Release is Lerna at 11.19.0, with @trpc/openapi published separately as 11.19.0-alpha. Docs are a Docusaurus app deployed with a large Vercel redirect map.

Feature catalog

User-facing surface area is the procedure builder (query, mutation, subscription), a middleware pipeline with pluggable validators, several HTTP and WebSocket client links, React Query hook and options-object integrations, Next.js SSR helpers, and framework adapters. Examples demonstrate the same API on Next pages, the Next app router, Cloudflare Workers, Express, Fastify, AWS Lambda, Bun, Deno, and Nuxt. Ancillary products are an OpenAPI generator CLI, a codemod upgrade CLI, and TanStack Intent skills shipped inside the packages.

All 14 feature catalog claims →

Data flow

A call is a typed operation that becomes an observable, passes through a link chain, and is encoded as JSON (or JSONL/SSE/WebSocket frames). On the server, getRequestInfo splits batch paths, deserializes inputs with the configured transformer, and resolveResponse invokes procedures with one shared context. Middleware, including validators, runs before the resolver. Outputs are serialized by transformTRPCResponse. Errors are a fixed shape keyed by JSON-RPC-style codes. Persistence, when present, is inside user resolvers, not the framework.

Behavior traces

Startup is initTRPC.create once per backend, then router({...}) which flattens procedures. An HTTP query or mutation enters through an adapter, resolveResponse, getRequestInfo, one context factory, the procedure middleware stack, and transformTRPCResponse. A chat send is a mutation that writes Drizzle and an SSE subscription that replays and tails an emitter. In-process calls skip HTTP via createCaller or unstable_localLink.

Testing signals

Unit and integration tests are Vitest projects rooted at every packages/* package, with jsdom, globals, Istanbul coverage, and two CI retries. The heaviest behavioral coverage is packages/tests/server (adapters, batching, streaming, websockets, regressions) plus colocated tests in server, client, and react-query. Playwright smoke tests live in selected examples and run in a GitHub Actions matrix that is allowed to fail. OpenAPI fixture drift fails the unit job. App-dir, upgrade, vendor, www, and examples are excluded from coverage.

Risk map

The framework does not authenticate requests; authorization is a user middleware. The risky defaults are unlimited Node request bodies, batching on with no max batch, stack traces in any non-production NODE_ENV, and transformer.deserialize running on attacker-controlled JSON. Several high-churn areas (Next app dir, the upgrade CLI, the SSE chat example) are outside the coverage gate or marked continue-on-error. WebSocket and HTTP stacks duplicate procedure invocation, so adapter bugs do not all flow through resolveResponse.

Extension points

New behavior is meant to plug in at initTRPC factories, the middleware and parser pipeline, client links, and HTTP adapters. Cross-cutting hooks are errorFormatter, transformer, responseMeta, createContext, and onError. Routers can be merged or lazy-loaded. Standard Schema is the validator seam. OpenAPI generation, the upgrade codemods, and the skills directories are the extension points outside the RPC runtime.

Contributor handoff

Read the procedure and HTTP core before editing. Tests run against source via Vitest aliases, but typecheck and consumers need pnpm build because packages ship dist built by tsdown. Keep adapters thin, put behavior changes in unstable-core-do-not-import, and add a regression under packages/tests. Do not treat examples or www as the library. OpenAPI fixtures are generated and checked in CI. Public types are the product, so signature changes are breaking even when runtime behavior is not.

Languages

LanguageFilesShare of source
TypeScript95996%
Markdown282docs/config
JSON149docs/config
YAML37docs/config
JavaScript263%
SQL131%
CSS6docs/config
TOML40%

Start reading here

Probable source entrypoint: packages/ — inferred from the directory tree and manifest, not the upstream docs.

Source roots

packages/ (659 files)

Repository structure

Top-level pathFiles
packages/659
examples/522
www/315
.github/22
.cursor/7
scripts/3
_artifacts/3
.superset/1

Docs found: CONTRIBUTING.mdREADME.md

Package

package.json — root, 37 declared dependencies.

@actions/core@actions/github@eslint/compat@ianvs/prettier-plugin-sort-imports@manypkg/cli@tanstack/intent@testing-library/dom@testing-library/jest-dom@testing-library/react@testing-library/user-event@types/event-source-polyfill@types/node

CI & config entrypoints

Structural health signals

Average score 6.8/10 across 96 analyzed source files; 29 hotspots surfaced.

These are deterministic review leads — size, churn, and structural signals — not proof of a bug in this project.

Recent history