tRPC 11.18
Last reviewed Sep 19, 2026
Prompt Details
Prompt Composition
4prompts
- JavaScript ES2026102 lines · 3.1K tokens
- Node.js 24101 lines · 5.3K tokens
- TypeScript 746 lines · 1.5K tokens
- tRPC 11.1866 lines · 3K tokens
Total315 lines · 13K tokens
CWE Coverage
- 20
- 22
- 59
- 73
- 78
- 79
- 88
- 89
- 95
- 113
- 117
- 200
- 201
- 208
- 209
- 214
- 250
- 295
- 297
- 306
- 319
- 323
- 330
- 338
- 346
- 347
- 352
- 354
- 362
- 367
- 377
- 426
- 444
- 459
- 471
- 488
- 494
- 502
- 524
- 532
- 598
- 602
- 613
- 639
- 653
- 732
- 770
- 772
- 807
- 829
- 838
- 862
- 863
- 908
- 915
- 916
- 918
- 922
- 942
- 943
- 1004
- 1321
- 1333
Prompt Preview
Apply the Node.js 24, TypeScript 7, and JavaScript ES2026 prompts first. These rules target tRPC 11.18.0 on Node.js, including HTTP adapters, server-side callers, WebSockets, and Server-sent Events (SSE). Apply host-framework controls as well when mounting tRPC inside another framework.
Procedures and authorization
- Initialize one shared
initTRPCinstance per backend so routers use consistent context, transformer, and error policies. Keep server implementations out of browser bundles; shareAppRouterthroughimport typeand leaveallowOutsideOfServerdisabled. - Export a
protectedProcedurebuilt witht.procedure.use(...)and require it for protected queries, mutations, and subscriptions. Baret.procedureis public; router nesting, anadminname, and.meta()declarations do not enforce access without executing a corresponding check. - Authorize the requested operation and resource within its tenant after validating identifiers. An organization ID supplied to
.input()is a selector to check against verified membership, not permission to enter that organization; scope data access to the authorized resource and derive ownership and privileged writable fields on the server. - Keep
.query()and subscription setup free of application state changes that require mutation authorization. Use.mutation()for those changes; HTTP queries and subscriptions accept GET, and clients may retry or reconnect them.
Context and middleware
- Resolve and verify credentials in
createContext; treat headers, cookies, andinfo.connectionParamsas untrusted until