tRPC

T

tRPC

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

Join

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

Is publicProcedure safe to use with this kind of approach ?

Stack : t3stack (next 14, drizzle, pnpm) I want to expose some of my procedure with rest api for an intern old software and I want to use an API KEY approach to secure it. I have this user.ts procedure that return info of my user based on id, and this authorization.ts procedure that check if the key is valid (it's the user id for now to make some tests). Does making the user procedure public make it vulnerable if it's used like the user/[id]/route.ts file ? ...

Need more control over error handling

This is coming up as a result of some security testing against our API where we discovered that malformed URIs result in 500 errors (which in turn hit our error reporter). We believe that these errors should be 400x errors, but it isn't entirely clear how to accomplish this. In this particular case, the URIError is generated by tRPC itself, not our procedures, which means it's not as easy as wrapping the procedure and throwing the appropriate tRPC error instance....

TypeError [ERR_INVALID_STATE]: Invalid state: Controller is already closed

I am getting this error ``` β¨― unhandledRejection: TypeError [ERR_INVALID_STATE]: Invalid state: Controller is already closed at new NodeError (node:internal/errors:405:5) at ReadableStreamDefaultController.enqueue (node:internal/webstreams/readablestream:1045:13)...

createCaller is returning [Function: noop]

env: node 20 pnpm I'm trying to call procedures locally, and when I console log the router, I see the trpc object ({mutations: ..., etc.}) But when I create the caller, it returns noop, and anything I call on that is noop. Ideas?...

Fastify + TRPC on Vercel

I am having trouble hosting a Fastify + TRPC server on Vercel. I have tried two different vercel.json setups, but they both do not work for each reasons: ```json { "rewrites": [...

Is it ok to have 2 clients in one app

Hi, as for the topic, is it okay to have a standalone client and a react-query integration? I have a trpc standalone backend in a monorepo with nextjs frontend, so far I've been calling my backend only from server components, now i think i will need react query functionalities in the client components, is it ok to have both standlone client and react query intefgration or is there a better approach?

Duplicated tRPC server-side calls

Hello, I'm using the CT3App tRPC implementation, server-side, with createHydrationHelpers stuff from @trpc/react-query/rsc I'm also using generateMetadata function from NextJS App Router. ...

Is it good choice to use tRPC if I don't use monorepo?

Is it good choice to use tRPC if I don't use monorepo? If so, how can I get the types and everything on client side? I can use shared NPM module, but it won't be painful to do that?

Equivalent to middleware on createNextApiHandler

Hey, I'm currently migrating our trpc app to the app router and wondered what the equivalent to the middleware property here would be in app router: ```ts import { createNextApiHandler } from '@trpc/server/adapters/next' ...

Issues with setting up t3-create-app and server side events(SSE)

Hello, I'm using practically out of the box t3-create app and try to set up project with using SSE. I've added splitLink and simple subscription onPostAdd as in example from docs page(https://trpc.io/docs/client/links/httpSubscriptionLink) However, when try get this sub on client api.post.onPostAdd type of onPostAdd is...

Is it possible to use tRPC React Query Integration without defining a trpc provider?

When using react query without tRPC the query client can be passed as an argument when using the hook. Example: const { data: inquiries } = useQuery( { initialData: data,...

Is it possible to request directly from user's browser rather than using a server proxy in trpc?

I have been using trpc in my project and it's been working really well. However, some requests need to be sent from the browser to the target API instead of our server. I am considering creating a React-Query API wrapper directly, but I'm concerned it might not align well with trpc usage. Is it feasible to implement something like this: ```ts import { api } from "~/trpc-browser" const res = api.something.useQuery()...