tRPC

T

tRPC

Join the community to ask questions about tRPC and get answers from other members.

Join
DDINO4/24/2024

What do you guys think about the approach of importing/exporting tRPC types to be used in separate B

Hello, I was looking for a way to share tRPC API between multiple electron apps, I thought first about using a Nx monorepo but it turned out it's almost impossible to make it work with electron app that use electron-vite. After more research I found this repo: https://github.com/mkosir/trpc-api-boilerplate...
JJulyWitch4/23/2024

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?...
Jjaacsen4/22/2024

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?
XXavierBread4/22/2024

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
EElven4/21/2024

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:...
Ggave_one4/21/2024

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
Jjlarmst4/21/2024

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:...
Sseven4/20/2024

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) {...
HAHamza Ali4/19/2024

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....
JJoel4/16/2024

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`, () => {...
CCircus4/16/2024

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?
EElven4/16/2024

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....
VVengeance4/15/2024

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...
HAHamza Ali4/15/2024

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....
TTime4/14/2024

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
Ssudo4/13/2024

Error on NextJs AppRouter

Anyone knows why this is showing on my console?
No description
RHRasel Hossain4/12/2024

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
Ssanti4/12/2024

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.
Rrhh4x0R4/11/2024

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