tRPC

T

tRPC

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

Join

[V11] BFF Monorepo setup

Hello! I have a monorepo with several apps, every app has its tRPC endpoint setup like this. ```typescript // app/api/trpc/[trpc].ts...

Is there any way to know which objects in a list got updated from a useQuery refetch πŸ€”

Or through another API type Have some larger calculations that happen after the list is set that I don’t want to recalculate...

[v11] Change responseMeta in procedure

Is there a way to do so? I need to add a cache header to one specific api. I found this doc quite confused me. I don't have createTRPCNext in my app (mine is app rotuer created from t3 template). And this seems a global caching rather than a single api route one. Thank you in advanced....

onSuccess not triggered when route changes

I have an generation modal, based on parallel routing in next.js. When idea starts generating, modal closes and route changes to previous. In this case actions, placed in "on" methods do not start. ```typescript const createIdea = async ( mutationFn: | typeof createFreelanceProjectIdea...

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?...
Next