trpc

31 mods across 1 repository, 41k stars between them.

coding-guidelines

01

trpc/trpc

Cursor rule Cursor

You are working on tRPC - a TypeScript-first RPC library that provides end-to-end type safety between client and server. As a TypeScript expert contributing to this library, you should.

41k 18d ago A 0 tokens original MIT

pnpm

02

trpc/trpc

Cursor rule Cursor

Always use pnpm as a package manager instead of yarn, bun, or npm.

41k 18d ago A 29 tokens original MIT

react-query-tests

03

trpc/trpc

Cursor rule Cursor

// ✅ CORRECT: Legacy React Query pattern const ctx = konn() .beforeEach(() => createAppRouter()) .afterEach((ctx) => ctx?.close?.()) .done().

41k 18d ago A 0 tokens original MIT

trpc/trpc

Cursor rule Cursor

// ✅ CORRECT: Use await using for automatic cleanup await using ctx = testReactResource(appRouter, { server: { // server configuration }, client(opts) { return { links: [ httpLink({ url: opts.httpUrl, // client configuration }), ], }; }, }).

41k 18d ago A 0 tokens original MIT

test-patterns

05

trpc/trpc

Cursor rule Cursor

// ✅ CORRECT: Use await using for automatic cleanup await using ctx = testServerAndClientResource(router, { client(opts) { return { links: [ httpLink({ url: opts.httpUrl, fetch: mockFetch, }), ], }; }, }).

41k 18d ago A 0 tokens original MIT

test-running

06

trpc/trpc

Cursor rule Cursor

When running tests, use the --watch false flag to avoid watch mode.

41k 18d ago A 83 tokens original MIT

upgrade-tests

07

trpc/trpc

Cursor rule Cursor

// ✅ CORRECT: Upgrade package pattern await using ctx = testReactResource(appRouter, { server: { // server configuration }, client(opts) { return { links: [ httpLink({ url: opts.httpUrl, // client configuration }), ], }; }, }).

41k 18d ago A 0 tokens original MIT

client-setup

08

trpc/trpc

Skill Claude CodeCodex

Create a vanilla tRPC client with createTRPCClient (), configure link chain with httpBatchLink/httpLink, dynamic headers for auth, transformer on links (not client constructor). Infer types with inferRouterInputs and inferRouterOutputs. AbortController signal support. TRPCClientError typing.

41k 18d ago A 63 tokens original MIT

links

09

trpc/trpc

Skill Claude CodeCodex

Configure the tRPC client link chain: httpLink, httpBatchLink, httpBatchStreamLink, splitLink, loggerLink, wsLink, createWSClient, httpSubscriptionLink, unstablelocalLink, retryLink. Choose the right terminating link. Route subscriptions via splitLink. Build custom links for SOA routing. Link options: url, headers…

41k 18d ago A 90 tokens original MIT

superjson

10

trpc/trpc

Skill Claude CodeCodex

Configure SuperJSON transformer on both server initTRPC.create({ transformer: superjson }) and every client terminating link (httpBatchLink, httpLink, wsLink, httpSubscriptionLink) to support Date, Map, Set, BigInt over the wire. Transformer must match on both sides. In v11, transformer goes on individual links, not…

41k 18d ago A 76 tokens original MIT

nextjs-app-router

11

trpc/trpc

Skill Claude CodeCodex

Full end-to-end tRPC setup for Next.js App Router. Covers route handler with fetchRequestHandler (GET + POST exports), TRPCProvider with QueryClientProvider, createTRPCOptionsProxy for RSC prefetching, HydrateClient/HydrationBoundary for hydration, useSuspenseQuery for Suspense, and server-side callers.

41k 18d ago A 74 tokens original MIT

nextjs-pages-router

12

trpc/trpc

Skill Claude CodeCodex

Set up tRPC in Next.js Pages Router with createNextApiHandler, createTRPCNext, withTRPC HOC, SSR via ssr option and ssrPrepass, SSG via createServerSideHelpers with getStaticProps, and server-side helpers for getServerSideProps prefetching.

41k 18d ago A 67 tokens original MIT

openapi

13

trpc/trpc

Skill Claude CodeCodex

Generate OpenAPI 3.1 spec from a tRPC router with @trpc/openapi CLI or programmatic API. Generate typed REST client with @hey-api/openapi-ts and configureTRPCHeyApiClient(). Configure transformers (superjson, EJSON) for generated clients. Alpha status.

41k 18d ago A 64 tokens original MIT

adapter-aws-lambda

14

trpc/trpc

Skill Claude CodeCodex

Deploy tRPC on AWS Lambda with awsLambdaRequestHandler() from @trpc/server/adapters/aws-lambda for API Gateway v1 (REST, APIGatewayProxyEvent) and v2 (HTTP, APIGatewayProxyEventV2), and Lambda Function URLs. Enable response streaming with awsLambdaStreamingRequestHandler() wrapped in awslambda.streamifyResponse().…

41k 18d ago A 93 tokens original MIT

adapter-express

15

trpc/trpc

Skill Claude CodeCodex

Mount tRPC as Express middleware with createExpressMiddleware() from @trpc/server/adapters/express. Access Express req/res in createContext via CreateExpressContextOptions. Mount at a path prefix like app.use('/trpc', ...). Avoid global express.json() conflicting with tRPC body parsing for FormData.

41k 18d ago A 67 tokens original MIT

adapter-fastify

16

trpc/trpc

Skill Claude CodeCodex

Mount tRPC as a Fastify plugin with fastifyTRPCPlugin from @trpc/server/adapters/fastify. Configure prefix, trpcOptions (router, createContext, onError). Enable WebSocket subscriptions with useWSS and @fastify/websocket. Set routerOptions.maxParamLength for batch requests. Requires Fastify v5+.…

41k 18d ago A 97 tokens original MIT

adapter-fetch

17

trpc/trpc

Skill Claude CodeCodex

Deploy tRPC on WinterCG-compliant edge runtimes with fetchRequestHandler() from @trpc/server/adapters/fetch. Supports Cloudflare Workers, Deno Deploy, Vercel Edge Runtime, Astro, Remix, SolidStart. FetchCreateContextFnOptions provides req (Request) and resHeaders (Headers) for context creation. The endpoint option…

41k 18d ago A 86 tokens original MIT

adapter-standalone

18

trpc/trpc

Skill Claude CodeCodex

Mount tRPC on Node.js built-in HTTP server with createHTTPServer() from @trpc/server/adapters/standalone, createHTTPHandler() for custom http.createServer, createHTTP2Handler() for HTTP/2 with TLS. Configure basePath to slice URL prefix, CORS via the cors npm package passed as middleware option.…

41k 18d ago A 85 tokens original MIT

auth

19

trpc/trpc

Skill Claude CodeCodex

Implement JWT/cookie authentication and authorization in tRPC using createContext for user extraction, t.middleware with opts.next({ ctx }) for context narrowing to non-null user, protectedProcedure base pattern, client-side Authorization headers via httpBatchLink headers(), WebSocket connectionParams, and SSE auth…

41k 18d ago A 68 tokens original MIT

caching

20

trpc/trpc

Skill Claude CodeCodex

Set HTTP cache headers on tRPC query responses via responseMeta callback for CDN and browser caching. Configure Cache-Control, s-maxage, stale-while-revalidate. Handle caching with batching and authenticated requests. Avoid caching mutations, errors, and authenticated responses.

41k 18d ago A 54 tokens original MIT

error-handling

21

trpc/trpc

Skill Claude CodeCodex

Throw typed errors with TRPCError and error codes (NOTFOUND, UNAUTHORIZED, BADREQUEST, INTERNALSERVERERROR), configure errorFormatter for client-side Zod error display, handle errors globally with onError callback, map tRPC errors to HTTP status codes with getHTTPStatusCodeFromError().

41k 18d ago A 63 tokens original MIT

middlewares

22

trpc/trpc

Skill Claude CodeCodex

Create and compose tRPC middleware with t.procedure.use(), extend context via opts.next({ ctx }), build reusable middleware with .concat() and .unstablepipe(), define base procedures like publicProcedure and authedProcedure. Access raw input with getRawInput(). Logging, timing, OTEL tracing patterns.

41k 18d ago A 63 tokens original MIT

trpc/trpc

Skill Claude CodeCodex

Handle FormData, file uploads, Blob, Uint8Array, and ReadableStream inputs in tRPC mutations. Use octetInputParser from @trpc/server/http for binary data. Route non-JSON requests with splitLink and isNonJsonSerializable() from @trpc/client. FormData and binary inputs only work with mutations (POST).

41k 18d ago A 75 tokens original MIT

server-setup

24

trpc/trpc

Skill Claude CodeCodex

Initialize tRPC with initTRPC.create(), define routers with t.router(), create procedures with .query()/.mutation()/.subscription(), configure context with createContext(), export AppRouter type, merge routers with t.mergeRouters(), lazy-load routers with lazy().

41k 18d ago A 56 tokens original MIT