tRPC

T

tRPC

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

Join

v10 useQueries does not return a stable reference

I though this code would work downstream for memos and callbacks, but it does not. The memo and effect are re-ran every render. Have I don't something stupid, here or is this intended? How would I memoize a derives values from the results? This code:...

strange behaviour with t3 trpc starter

I had copied the provided create-post component and created a duplicate create-video component, exact same just different db table. https://github.com/rverma-dev/t3-app-bug/commit/d08f1ca79e3dcbba6033b477308a14b7ee530536. However the page gets rendered and immediately it error out Error: ❌ Attempted to access a server-side environment variable on the client. Kind of looking at it for last 4-5 hours but no luck at all. The code is exact same as of create-post but don't work....

Websocket connects even without any subscriptions

Currently, when I add a WS link, it tries to connect to the server right away. How can I prevent this behavior and allow it to connect only if there are any active subscriptions? Unlogged users don't have subscriptions, so they should not connect to WS server

calling tRPC procedures from a function (e.g. a cron on vercel)?

Hey everyone, I am using nextjs App router together with tRPC and it's working super well so far! I would like to call tRPC procedures periodically (like once per month with a cron job) and also from a function (e.g. user submits a form, once it's sucessfully submitted, I wait 5 seconds and then call a mutate procedure that updates stuff in my DB)....

How to serialize and deserialize an object of a custom class?

I have a custom class and i want to send objects of it over trpc, but the serialization is not working properly. The date fields are being converted to strings.

Header caching

Hello all, I am sending an authorizaton token ```js export const TRPCProvider: React.FC<{...

You must define a transformer on your your `initTRPC`-object first

Hey, getting an odd error, pretty much booted up a ct3a stock application, and getting these errors. When there seemingly IS the transformer on the init trpc object... I think that ct3a is using the v11 release candidate, so i dont know if there is anything breaking in there? Any help is appreciated!...
Solution:
I had messed around with tsconfig and turned off strict mode. Apparently this is a no go. When i turned it back on, the issue was solved.
No description

trpc + unstable_cache (Next)

What is the recommended way to work with trpc + unstable_cache? For now I am creating functions wrapped inside unstable_cache and call procedures inside this function. Is there any easier way?

How to set up custom response headers at procedure level

hello guys, i'd like to know how to set up custom headers per procedure. I am aware of the responseMeta, but thats general. I'd like something more fine-grained. Something like this but doesnt work: ```ts...

Subscription example not behaving like it should

Hey, I've recently wanted to make a subscription route and I've stumbled upon a problem. In the documentation it's said that you should return an observable with a callback that is triggered immediately. That however is not happening. I don't know if I don't understand this correctly of if the example is broken. I'm using bun@1.1.10 with @trpc/server@11.0.0-rc.396. ```ts...
Solution:
Okay I get it now, in my actual project I was using httpBatchLink and wsLink together insead of splitting them using splitLink that's why the subscription wasn't going off. ```ts export const api = createTRPCClient<AppRouter & WebSocketRouter>({ links: [...

nodeHTTPHandler with Nitro

I'm trying to setup trpc with nitro.unjs.io using the node-httpadapter. ```ts import { nodeHTTPRequestHandler } from "@trpc/server/adapters/node-http"; import { appRouter } from "~/lib/trpc/router";...
Solution:
Nvm, it seems to work like this. Have to return the correct response of course (which revealed another error with the path). ```ts export default defineEventHandler(async (event) => { console.log('trpc route handler');...

Cookies not being passed on to client

Hi all, I can't tell if I'm simply trying to wrangle TRPC into doing something it's not designed to do, or if I'm just doing it wrong. I'm using trpc to proxy our auth server, something like: ``` .mutation(async ({ input }) => {...

Does the fastify adapter support content-type multipart formdata on v11?

I saw that recently formdata support was merged in, and i was interested if the fastify adapter supports it and does it need @fastify/multipart?

NextJs Setup: `useContext is not a function`

Env: Bun 1.1.10 This morning I started following this guide to setup tRPC in my existing NextJs project https://trpc.io/docs/client/nextjs/setup ...
No description

TRPC response data changing to undefined when typing in a form field.

Hello, I'm currently having a very strange issue, I am using a form to input some data and send off to a trpc endpoint to retrieve some data from the server when I click the submit button. However, the respnose userData variable is being changed to undefined whenever I type into the form field. I am not sure why this is happening as I do not mutate userData anywhere, and there are no new TRPC queries running (verified checking network tab) and the TRPC endpoint is set to disabled. So it will only fetch data once I call the refetch function... Anyone have any idea?...

Trpc in monorepo with microservices

Hello, so I have monorepo with multiple services. Each client currently has 1 backend for it so it was working well so far, however now I'm building new services (backend only) and I want to either contact them as well through my client (means 1 client should have multiple trpc clients) or my trpc servers should be able to communicate between themselves. What would be the preferable approach and are there any best practices developed on this front yet?

conditionally fetching data with a useQuery

Hello, From my understanding a useMutation is primarily for updating/deleting/creating a record. And a useQuery is primarily used for fetching data from the server. However, when it comes to conditionally fetching data from the server I belive the syntax for a useMutation is much more ideal? I'm not sure if I am missing something, or if in this scenario it would be better to use a useMutation....

Using trpcState with Remix

Following the guide, seems like the serialized stuff is sent down, but not used by the client.

integrating with Meteor

I have made a simple app with express before and now I am trying to get a proof of concept running with Meteor.js. Meteor has a webApp component that behaves much like an express handler. For example, I can do this: ``` WebApp.connectHandlers.use('/trpc', ...