tRPC

T

tRPC

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

Join
NNicoFish4/28/2024

Change db url in ctx with an API call

I want to have a switch in my frontend to change from dev db to prod db. I'm using prisma. Have 2 prisma instances (one for prod and the other for dev). Is there any way to override the prisma instance in the ctx with an API call?
AAphirox4/27/2024

TRPC Docs Generation

Hey, I want to generate a swagger-like interface to document my TRPC api. However, I don't want to use trpc-openapi because I don't want to have to map the endpoints to be restful. I just want to directly generate docs for the rpc calls without converting it into openapi. I found a package that does exactly this, but now I can't find it again for the life of me. Would anyone know which package does this?
XXavierBread4/27/2024

error: NEXT_REDIRECT

Hi I'm doing a server call in RSC, but it crash the app and show this kind of error where shows in the pic. So, how to make a redirect when user validation failed in a trpc middleware? this is minimally reproducible code https://github.com/Dieber/t3-test-redirect...
No description
BblueWhale4/27/2024

Is there a way to use TRPC React Query Integration with Nanostores instead of the Context API?

Currently we use TRPC by wrapping out application in a TRPC context provider. However, in some use cases, such as an Astro App, we don't want to wrap our entire app in a React Context. A common solution is to share state between Astro islands using nanostores (https://docs.astro.build/en/recipes/sharing-state/). I wanted to know if there is any way to share the TRPCReact client between Astro components using nano stores, without needing to use a React Context Provider. We can already share the React Query client between components using nanostores by passing the client as a parameter to the useQuery function. However, I could not find an option to pass the trpc client in the same way. I would greatly appreciate any help on this....
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
Next