tRPC

T

tRPC

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

Join

First time learning trpc really good tool. help with setting cookies on front end.

Hello how do you use tRPC to make a cookie and send it to the front end. or is there any other method to make some auth stuff with the next auth.

How do we add settings in each query like before?

Since the new update, bee super confused. I used to do this, and can't recreate it now. ``` const { data: traitz, isLoading,...

Handling error globally

According to the docs on errors https://trpc.io/docs/v10/error-handling I should get such error object on client side when its thrown from procedure If I understand correctly. But Im having a problem with it as it doesnt seem to be typed as TRPCError on the client and dont contain few props from described in docs. ```js queryCache: new QueryCache({ onError: async (error: any) => {...

cant access trpc endpoints via the browser

i'm converting some express endpoints to trpc, and I cant figure out how to access my endpoints via the browser for example http://localhost:3000/trpc/getbytenantid my trpc endpoint ```js...

tRPC without SSR

When using tRPC with ssr it uses getInitialProps, which has kinda of a cool effect in terms how a page is rendered, since it's rendered server-side on initial requests and client-side on route transitions. Unfortunately, enabling ssr means that you can no longer use getServerSideProps (which I know is only fixable by next.js and not tRPC). But how to replicate the getInitialProps behaviour then? Let's say I'm building a blog; due to SEO it's basically necessary to render my posts server-side. But when navigating through the site loading posts on the fly would be totally fine. How to do that without ssr?...

trpc + expo react native issue

Does anyone know how to solve this? Im not familiar with webpack at all. I’m a junior frontend....

Can you chain middlewares in v10?

Would I be able to make a rate limit and isAuthed middleware, then put queries behind both middlewares so it's rate limited and protected by auth? The docs suggest it doesn't work like this, but I wanted to make sure.

Load data client-side via react-query while using tRPC with SSR

Is there any way to load data client-side when using tRPC? I want my page to be rendered and load data dynamically, since this data is not SEO-relevant. As far as I'm understanding as soon as I turn on SSR in tRPC queries must be done before the page is rendered.

Serving clients in another repository?

Would it be possible for tRPC to act as a server for clients in another repository and if so how would that work? šŸ™‚

How to access hooks while initializating react query client for nextJS?

Usually when initialing react query client this happens in the react component scope. Considering we are not using SSR is quite useful to define global queryCache to handle errors or display toastr, etc. The way trpc initialize the react query client with nextJS using the createTRPCNext doesn't give the option to access/call any hooks. There is any other way to initialize trpc on NextJS that happens in the react component lifecycle as it would happen if we'are using only react query?...

How to execute mutation outside of react context?

Hi! I'm slowly converting code over to v10 - looks great! However, I ran in to an issue when using tRPC within my xstate state machine. I need to run a mutation in one of my states, and since this runs outside of react context, Alex had instructed for me to do the following in v9: 1. set the following property on window in _app.tsx ```...

When not to use tRPC?

Is there any scenario when building a mobile and/or a web app with backend that you would not recommend people to use tRPC? (We can assume that all the FE clients will be in the same repo) Are there any limitations / cons of using tRPC over using something like Fastify / Nestjs / Nextjs (without tRPC)?...

Bi directional infinite query example with prisma

I'm working on a project that is using this pattern, but my hasPreviousPages gets blown away when I go to the next page. Anyone have an idea what might be happening?

Websockets not sending data

Hi, I have a websocket route that doesn't seem to be sending any data I added a setInterval to test it but it doesn't seem to be working Version: 10.0.0-rc.1...

Query keys

Hi! I'm super new to TRPC and based on my understanding, TRPC has a thin wrapper around react query. So, I'm wondering how to include the query keys when using trpc. Thank you! ```ts...

Possible to use tRPC proxy client inside Edge Runtime?

Hi, im trying to fetch a route from trpc inside a Vercel Edge Runtime function. Therefore im trying to create a ProxyClient from @trpc/client and importing it in the Edge function: ```ts...

v10 migration using codemod

So I've been looking at the codemod that helps with transition towards v10 and I haven't been able to get it to work, my setup (simplified): ```md // the following structure is inside /server/trpc/src...

NextJS 13 compability.

Is trpc compatible with nextJS 13? Should we use the default SSR into server components?

SSR and loading indicators - I don't get it

Guess I'm missing something here, but unfortunately I'm having a hard time with the docs: in https://trpc.io/docs/v10/nextjs the example utils/trcp.ts sets ssr: true, but the pages/index.tsx example uses ``` const hello = trpc.hello.useQuery({ text: 'client' }); if (!hello.data) {...