Skip to main content
@usenarrator/plugin-trpc The tRPC plugin reads a router as a list of procedures with their dotted paths, so post.byId reads as “the post.byId query” with the input it takes and the steps of its resolver. Middleware reads as checks that run before a procedure, and TRPCError codes are named together with their HTTP status. On the client, calls read as running a query or a mutation by path.
Add the zod plugin as well if your procedures validate input with zod, so .input(...) reads as the shape it accepts. The plugin declares library: { name: "@trpc/server", versions: ">=10 <12" } and reads both v10 and v11. It narrates files that import from an @trpc/* package, files that import a tRPC setup module (for example a ~/server/trpc file or names like publicProcedure), and files in a package that depends on tRPC (see Dependency detection).

Examples

A router with procedures
English
Middleware
English
The vanilla client
English

What it covers

  • Setup: initTRPC with its context, meta and options, and the exported router, procedure and middleware builders.
  • Routers: nested routers with dotted paths, mergeRouters, createCallerFactory, and procedures built from input, output, use, meta, query, mutation and subscription.
  • Middleware that checks the context and calls next({ ctx }), and TRPCError with its code and status.
  • Adapters such as fetchRequestHandler, createHTTPServer, createNextApiHandler and createExpressMiddleware.
  • Clients: createTRPCClient and its links, createTRPCReact hooks (useQuery, useMutation, useUtils and the cache helpers), skipToken, and the TanStack integration’s queryOptions and mutationOptions helpers, which the TanStack Query plugin reads as queries.

Translating

The English phrasebook is exported as en and typed as TrpcPhrases.