tRPC

T

tRPC

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

Join

How to add fallback link to tRPC link (Mirror API URL if main URL failed)

My API URL is not functioning in Iran, I'm using Vercel and Vercel has banned Iran, I want to provide a different URL as a mirror API URL in case the main URL fails, How can I do that using tRPC links?...

How can I show real-time post's replies/comments after a successful a reply mutation?

After submitting a successful reply mutation, I want to show a real-time UI update on my frontend?

Quick question: how to get mutation body in a middleware, which is for a global logging?

Hi everyone!Quick question: The pic shows that the output of "input" is undefined. Is there any another way to get it?...
No description

Error with v11 when using batching

I'm using the lastest version of v11. When I use the batch link I get an trpc inernal error when batched request are received. I'm using HonoJS, bun and v11. Stack trace:...

tRPC failed on <no-path>: `headers` was called outside a request scope

I'm using NPM GET /api/trpc/post.test?batch=1&input=%7B%220%22%3A%7B%22json%22%3Anull%2C%22meta%22%3A%7B%22values%22%3A%5B%22undefined%22%5D%7D%7D%7D...
No description

v11 `Invalid Content-Type header`

The most recent update of v11 seems to break with:
Invalid Content-Type header. This request may not be supported by your tRPC Adapter, or possibly by tRPC at all
Invalid Content-Type header. This request may not be supported by your tRPC Adapter, or possibly by tRPC at all
The related commits in the rc.346 are probably:...

Calling procedures from Next server actions

Hi, is using trpc client allowed in server actions? I have two use cases, in one i call procedure from server component with the 'use server' ``` 'use server'; export async function getCandlesticsData(symbol: string, interval: KlineInterval) {...

TRPC Typescript auto serialize error

The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed i have tried merge routers but its still not working If someone had encountered this issue and resolved this please let me know....

TRPC with MSW

Does anyone have a basic example on how to set up MSW in a React Vite TRPC env? My main question is, how to use MSW to mock my TRPC requests. In a non TRPC environment my handlers looks like this: ``typescript http.get(/api/my-svc/foo`, () => {...

Revalidate / invalidate in server components

Is there a solution for TRPC query invalidation (or revalidating), passing the actions from the client component where the action happens to server components? So far, I've only seen examples where you have to turn the respective server components into client components. Are there any better solutions?

Typescript type error with latest version

I'm initialising a project with trpc v11 and I'm trying to strictly follow the documentation for react-query. I face a problem: everything works fine at runtime but in vscode I have 2 typescript errors: 1/ My hello procedure get this type error on useQuery : Property 'useQuery' does not exist on type 'never'.ts(2339) on this line const q = trpc.hello.useQuery("thing"); in my component....

Don't understand cache

How come my API is still getting called when it's already been called with other inputs? Ex: 1. api fetch with 1 as the input 2. api fetch with 0 as the input I expect if the input gets set to 1 again, the API would not be called because we already fetched the result for that...

The inferred type of this node exceeds the maximum length the compiler will serialize.

I'm facing this issue. The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed i have tried merge routers but its still not working If someone had encountered this issue and resolved this please let me know....

Getting strange react error in nextjs

I am getting a strange Error Message when nextjs tries to compile: ```js TypeError: reactWEBPACK_IMPORTED_MODULE_1.useContext is not a function at Config (./src/components/developer/config.tsx:13:80)...
No description

Error on NextJs AppRouter

Anyone knows why this is showing on my console?
No description

TRPC Dynamic Procedure URL

I am currently using QStash as a message queue with TRPC. QStash is HTTP-based and in the example below, you can see that I call the TRPC procedure URL when publishing a message using QStash. My question is, how can I make this URL dynamic? Instead of repeatedly writing the full URL, I want to use a function call like
js
trpc.subscription.updateSubscription.url
js
trpc.subscription.updateSubscription.url
. how can I do this in trpc?...
No description

Is it possible to get the procedure name / id in middleware?

I want to create a caching middleware that in some routes, stores a cache key that contains the route id (example: catalog.product.findMany) and the input (example: { categories: shirts }). It's not clear to me if this is possible.

tRPC + React Query Data Invalidation?

Hey y'all, I'm working with tRPC and React Query and just trying to understand how this works. I have a call that basically sees if the server is online or offline, however, when I disconnect the server I'll get the error eventually on the client, but it won't nullify the query data. Is that normal? Perhaps it just keeps it in the cache -- can I invalidate it to get the proper info? Ex. it'll show online when it's up, but when I turn it off it'll show... error fetching...

trpc optimistic updates causing data flicker

I'm trying to add optimistic updates to a calendar component but when the mutate function is called there's a flicker in the existing events