tRPC

T

tRPC

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

Join

Right way to structure your code when using tRPC?

I was wondering how you properly structure your tRPC ruter code? Writing all the code in the routers can become messy quickly. Do you split it up in controller and service files (MVC)?

React Native Usage

Hello, I wanted to know if trpc can be used with react native ? And is it possible on a bare react native cli project ? Thanks, have a nice day !...

How can I cache a single procedure?

I've seen the docs on caching here: https://trpc.io/docs/caching But that is caching the entire app router. my app router has many "subrouters" (Not sure what you call them) and I need different cache times for different "procedures" in those routers....

transformers, tensor.js, PyTorch and tRPC

dumb question: does anyone has experience with tensorflow.js? is there any major obstacle to use tensorflow.js rather than PyTorch and tensor? Just wondering if there could be any future difficulty using t3 stack while having transformers and embedding models to generate output at the backend

subscription

How do you guys Authenticate / Authorize Subscription ?

NextJS and createProxySSGHelpers context type error

Hi guys, do you guys know a better way of clean this typescript error? createProxySSGHelpers({ router: appRouter, ctx: await createContext({...

Validating Permissions

Hi! A common operation that I'm doing in tRPC is validating that a person has permissions to perform the action they're trying to do, i.e: ```typescript...

Any typescript chads able know if it's possible to map a type to another type w generics

Not 100% sure if this is appropriate to ask here but I figured there's a lot of good TS developers on this discord.. let me know if I should remove. Is it possible to use inference to somehow map one object type to another type generically? I know we can do it w/ strings but what about full objects? IE...

Type safety with enabled option

https://tkdodo.eu/blog/react-query-and-type-script#type-safety-with-the-enabled-option What is the best way to solve this with trpc? ```ts function useSessions(userId: number | null) {...

useQuery enabled not working???

Even setting the enabled to false --> trpc.order.get({id: "123"}, {enabled: false}) still makes the request

`QueryClientProvider` not included in `withTRPC`?

Trying to use import { useIsMutating } from "react-query" but it's throwing Error: No QueryClient set, use QueryClientProvider to set one We have the trpc.withTRPC(MyApp) with Next.js to add the tRPC provider - expected that this wouldn't also add the QueryClientProvider?...

Handle React error boundary

Seems like Im doing something wrong as I can't handle the error boundary from trpc query. I've queryClient with useErrorboundary set to true and wrapped my component that uses trpc query with the React Error Boundary but it doesn't seem to be able to catch it. When I just throw before the query it successfully intercepts the error but from trpc seems its not doing that? Am I doing something wrong ?? ```js const [queryClient] = useState(...

Any tips for Typescript slowness?

We successfully migrated from 9.x to 10 but are still seeing slow VS Code perf (10+ seconds to get any type info) are there any strategies we can use to minimize this?

Change status of useMutation from 'success' back to 'idle'

Hiya, I have a mutation for creating stuff that can run a few different ways on a page, and I want to change its 'success' status back to 'idle' after 5 seconds. Is there a programmatic way to change a mutation's status from 'success' back to 'idle'?

Is it possible to call one procedure in another?

I have multiple routers in my trpc server. For example userRouter (e.g. procedure: getUser) and postRouter (e.g. procedure: updatePost). Is it possible to call the getUser procedure from my userRouter in my updatePost procedure? Or are all procedure effectively independent....

Handling Query Errors at Root of App (v9)

I want to show an error toast on my NextJS frontend every time there is an error from useQuery in a functional component. Is there a way to add something at the root of my app that can watch for trpc errors or do I have to handle it at every use of useQuery? (note: i am on v9)

tRPC Client webpack error

As soon as I add the client part to my legacy app i get an error and Can't figure out what is wrong. ```js Version: webpack 4.35.3 ......

cookies, headers and authentication

in express I can do something like res.cookie("name", "value") for example. alternatively I can do res.set"set-cookie", "name=value"). how can I do something one of the two above with trpc? ...

remove query

is there any api on the trpc client to instantly remove the query out of the query cache? Basically this https://tanstack.com/query/v4/docs/reference/QueryClient#queryclientremovequeries

trpc hook pattern. This works, but I’m not convinced…

I want to call my route when a button is clicked and have access to isLoading, onError etc… I have implemented a pattern using ‘’refetch()’’ but it doesn’t feel ‘correct’ is there a better way of doing this. I will also create a custom hook out of it. ‘’’js const { refetch } = trpc.authDomain.signIn.useQuery( { email: userEmail },...