tRPC

T

tRPC

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

Join
SWSycamore Willow5/3/2024

How can I use multiple DBs with trpc in T3 app?

I'm cross posting to T3 Discord as well. Here's the Q: Hey all, I'm using T3 for a proof of concept at the startup I work at. I'm really really digging this stack and want to pitch it to our team to replace our current stack. I've chosen to work with Drizzle, can explain more why if necessary but will wave my hands at that for a moment....
Aaspizu5/3/2024

How does tRPC work?

I have a few quesstions regarding tRPC How does tRPC achieve type-safety without code-gen? Can tRPC work purely over websockets?...
CCPG5/2/2024

How to disable Next.js draftmode in tRPC?

Hi guys, is it possible to disable the Next.js draft mode using tRPC? I am tryin to achieve something such as this: ``` import { draftMode } from 'next/headers';...
RHRasel Hossain4/30/2024

Handle Multipart form data.

how to handle multipart form data using Trpc. I want to upload an image to a file storage service. using trpc procedure.
Mmwinel4/30/2024

Running Websockets/Subscriptions with Fetch / Edge Runtimes Adapter

Hi, has anyone been able to use trpc websockets/subscriptions? I am having challenges setting up the ws server using Fetch / Edge Runtimes Adapter and running it either in dev or production mode. Tried to follow the docs but it does not highlight this bit. I am using Node 20> and pnpm. Here is my route handler...
Llemonek4/29/2024

TRPClientError: Unexpected character

Hello, I am working on an Expo app and I seemingly randomly get the error in the picture. I don't really know why because I send many requests and sometimes it happens and sometimes not. I can provide any code that could be helpful. This the project repo: https://github.com/lmnek/run-app (I use npm and these packages ├── @trpc/client@11.0.0-rc.359 ├── @trpc/react-query@11.0.0-rc.359...
Solution:
Usually a sign that something between the client and the server isn’t working in the infrastructure
No description
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`, () => {...