tRPC

T

tRPC

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

Join

Object keeps getting overwritten

I feel like i'm missing something fundamental here. when I add a new entry into object b it resets to an empty object upon a subsequent request. Can anyone help? ```js addNewTicket: ticketsDomainProcedure .input( z.object({...

AccessToken for API calls

What would be the best approach to pass the AccessToken from NextAuth Session to the Http Client which is being called from tRPC procedures to access external API?? Should I attach the AccessToken to the request object from NextAuth session callback and then provide it to the HttpClient instance in the tRPC context initialization for the request?? Or is there better alternative to handle this?...

Request or Response Specification Definition Document

I am developing a backend service using trpc, but I need to dispatch trpc in another programming language. I would like to know the design specification of trpc related requests and responses so that I can implement it in other languages....

abortOnUnmount config error

I'm encountering an error when passing abortOnUnmount saying that it does not exist as a possible param. I'm basing this off the v10 docs. Am I missing something here? My implementation: ```ts const [trpcClient] = React.useState(() =>...

zustand + trpc (basic data fetching)

im trying to use zustand with trpc, but having trouble setting some data to global state. What am i missing here? ```js import create from 'zustand'; import { trpc } from '../../utils/trpc';...

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