tRPC

T

tRPC

Move Fast & Break Nothing. End-to-end typesafe APIs made easy.

Join

Caching API calls (HTTP response)

I'm using tRPC with Analog.js, I'm wondering if this is possible to be implemented. Where I could cache API calls, and clear cache on certain conditions (non-get request).

TextDecoder not implemented Trpc react-native httpBatchStreamLink

Receiving the stream relies on the TextDecoder and TextDecoderStream APIs, which is not available in React Native. If you still want to enable streaming, you need to polyfill those. any refrence to this?

Generating Types in v11

I am trying to generate types with tsc --declaration in order to import the type for the app router into a different project. Is this use case supported in v11? the app router changes to any type after upgrading, and the declaration files reference these "do-not-import" files

Good patterns for large list querys? Invalidation & refetching gets slow after a mutation

We have several large lists where we invalidate the query after editing an item. What are some good patterns for this? The network lag starts adding up for the customers with more data. Ironically those who use us the most 😄 Is it "good practice" to edit the list query cache directly in the mutation onSuccess? Or necessary to refactor the list querys to be smaller, through server filters or infiniteQuery? Especially painful in a view where we have two lists where the user can connect items from one list to the items in the other list. Requiring both list queries to be invalidated. Better to make the "connections" mapping its own api procedure and only invalidate that? Or combine all three to one query, set the cache state manualle in the mutation onSuccess? ...

TSC errors after upgrading to v11

Hello, I am trying to upgrade to v11 and encountering the following error: ``` tsc --declaration --emitDeclarationOnly ...
Solution:
fixed by adding the "DOM" lib to my TS config

Router output types not mapping?

I can get it manually, but can't get it with inferRouterOutputs, returns unknown. Any ideas? Attached screenshots showing the issue
No description

trpc with Nuxt 4

I'm having trouble trying to use trpc with Nuxt 4. I've moved plugins to the app directory as per the new structure, but following the trpc-nuxt instructions otherwise (https://trpc-nuxt.vercel.app/get-started/usage/recommended). The returned $client value is a Proxy instance that has no capabilities otherwise. Anyone able to provide some insight as to the issue, or perhaps a better way to go about it? Perhaps using trpc directly without any Nuxt-specific bindings? 🤔...

how can i create a router off of a JSON?

is it possible to create a route dynamically off of a JSON? lets say i have: ``` appRouter = this.trpc.router({...

v11: inferRouterInputs is returning `void | <zod object>` so it's unusable?

can't see what I'm doing different than docs would be really cool if this worked ``` ...
No description

How do I create a React/Node full-stack project with tRPC?

Hello, I would like to build a website using React and Node and tRPC. What I first assumed is I need to scaffold a react app using Vite in a folder called client, write my server code in a folder called server ....
No description

calling tRPC procedure from custom link

what is the best way to call a procedure from a custom link? I see in https://github.com/pyncz/trpc-refresh-token-link they are using a helper client. I tried the proxy client approach with await utils.client.auth.refresh.mutate(tokens), but getting Error: Unable to find tRPC Context. Did you forget to wrap your App inside withTRPC HoC?.

Type too complex to infer?

Hey, I have a working router where types are infered properly, but no matter what I try I can't get this one to work
No description

Mongo Db Schema _id(ObjectId) in trpc get serializes to string

Hello there, In the mongoDB schema there is _id field with the type of ObjectId. But during serilization from trpc on the server its get converted to a string type. On the client the Mongo DB type gives a error that the _id type is string and not ObjectId. ...

Passing input as a prop

Hey all, I currently use zod to define my inputs for queries. Is there a good way to type the zod objects when passing them as props? Specifically I'm writing validation functions to verify the patch against business logic. I'm currently typing per my image but that is messy + not scalable.
No description

Useless TRPC Error messages: Error: ❌ tRPC failed on <no-path>

Environment * Node: v20.12.2 * Package manager: pnpm * Stack: T3 Stack * Environment: localhost...

subscriptions net::ERR_INCOMPLETE_CHUNKED_ENCODING 200 (OK) with httpSubscriptionLink on Bun/Hono

When using the Hono (Bun) middleware as per the instructions and setting up a tRPC subscription, the following error is thrown in the console, and a loop is created that eventually leads to a memory leak at the server:
net::ERR_INCOMPLETE_CHUNKED_ENCODING 200 (OK)
net::ERR_INCOMPLETE_CHUNKED_ENCODING 200 (OK)
I don't see this with the equivalent Node http server. Is anyone else using tRPC subscriptions successfully with Hono?...

Is publicProcedure safe to use with this kind of approach ?

Stack : t3stack (next 14, drizzle, pnpm) I want to expose some of my procedure with rest api for an intern old software and I want to use an API KEY approach to secure it. I have this user.ts procedure that return info of my user based on id, and this authorization.ts procedure that check if the key is valid (it's the user id for now to make some tests). Does making the user procedure public make it vulnerable if it's used like the user/[id]/route.ts file ? ...

Need more control over error handling

This is coming up as a result of some security testing against our API where we discovered that malformed URIs result in 500 errors (which in turn hit our error reporter). We believe that these errors should be 400x errors, but it isn't entirely clear how to accomplish this. In this particular case, the URIError is generated by tRPC itself, not our procedures, which means it's not as easy as wrapping the procedure and throwing the appropriate tRPC error instance....

TypeError [ERR_INVALID_STATE]: Invalid state: Controller is already closed

I am getting this error ``` ⨯ unhandledRejection: TypeError [ERR_INVALID_STATE]: Invalid state: Controller is already closed at new NodeError (node:internal/errors:405:5) at ReadableStreamDefaultController.enqueue (node:internal/webstreams/readablestream:1045:13)...

createCaller is returning [Function: noop]

env: node 20 pnpm I'm trying to call procedures locally, and when I console log the router, I see the trpc object ({mutations: ..., etc.}) But when I create the caller, it returns noop, and anything I call on that is noop. Ideas?...