Use this tag for tRPC, the TypeScript library for defining and using type-safe APIs for use with TypeScript servers and clients. For Remote Procedure Call, use [rpc] instead.
Questions tagged [trpc.io]
124 questions
0
votes
0 answers
How to narrow down the type usequery data with suspense and react-error-boundary?
I am using react query
the data received after usequery contains undefined. I want to remove undefined from this data.
usingQuery
enter image description here
root.tsx
enter image description…

윤지만jimmy.im
- 1
- 1
0
votes
0 answers
My t3 app wont build. Module not found: Can't resolve 'v8
Let me start off by saying i'm really new to this, so this might be obvious to some of you...
I am trying to build my NextJS project but it fails to compile. The errors i'm getting are the…
0
votes
2 answers
All my TRPC queries fail with a 500. What is wrong with my setup?
I am new to TRPC and have set up a custom hook in my NextJS app to make queries. This hook is sending out a query to generateRandomWorker but the response always returns a generic 500 error. I am completely stuck until I can figure out this…

Ken
- 91
- 4
0
votes
1 answer
trpc - Calling a route inside itself
Based on the documentation here, you can call another route on the server side using the const caller = route.createCaller({}) function. However, if the route is within itself, is it possible to do so using the this keyword? If not, how can one call…

wongz
- 3,255
- 2
- 28
- 55
0
votes
1 answer
Next-Auth signIn: Promise-returning function provided to attribute where a void return was expected
is giving the following @typescript-eslint/no-misused-promises error in VS Code: Promise-returning function provided to attribute where a void return was expected.
I am following this tutorial:…

currenthandle
- 1,038
- 2
- 17
- 34
0
votes
1 answer
Typescript overloading unnamed function in trpc
I have a typical trpc route. It fetches posts. If there is an id argument, it fetches 1 post. If none, it fetches all posts. What is the syntax for overloading an unnamed function, and where do I put the overload code in this case?
publicProcedure
…

wongz
- 3,255
- 2
- 28
- 55
0
votes
1 answer
tRPC setData hook doesn't have access to all data for optimistic ui updates
I'm building out mutations with tRPC and React Query that optimistically update my UI when a new item is added, but I'm running into a problem.
The query that I'm updating expects a certain number of properties that are either auto-generated, such…

Jesse Winton
- 568
- 10
- 33
0
votes
0 answers
Null session on first useQuery after reloading page
I'm developping an application with a Next, TRPC and NextAuth (and Prisma but I believe there no issue with that one).
I have a page which displays a collection of elements. It retrieves the collection via an authenticated TRPC useQuery :
function…

PeO
- 63
- 7
0
votes
0 answers
How can I run an asynchronous function in a Custom Link? (resolve race condition with refresh token of third-party provider)
I'm having a very specific problem in which I use a third-party authentication provider (Clerk) that invalidates and refreshes their token in the browser very frequently (1-2 minutes). But Clerk is only able to run js and refresh the token if my…

Teodoro
- 1,194
- 8
- 22
0
votes
1 answer
Rerendering of one sibling component due to data update in other sibling component in Next JS
I have a Next JS app where I am using Layout feature in the _app.tsx component. I am showing a sidebar in the layout which is getting populated from an api call(get request).
Now I have another api call (update request) on button click in Index.tsx…

Sandheep Kumar Patro
- 75
- 1
- 5
0
votes
1 answer
How to redirect on tRPC error in SvelteKit?
I am using tRPC with SvelteKit for the first time, and I am stuck trying to validate the user's authentication.
I have the following in hooks.server.ts:
import { createContext } from '$lib/trpc/context';
import { router } from…

Basil
- 488
- 1
- 15
0
votes
0 answers
Issues using setData(id, newData) from trpc.useContext() -> typescript not accepting string as input
Currently exerciseId flagged on line with // Typescript Error isn't being accepted, resulting in the following Typescript Error:
Argument of type 'string' is not assignable to parameter of type 'Updater<"" | ExerciseWithFavourited | null |…
0
votes
0 answers
Inconsistent Type assertion in typescript when in Trpc publicProcedure (with prisma)
I am trying to create a public procedure to query a product that is stored in my database. If the product is not found, I am asking Prisma to throw an error, in fact, I am using the findUniqueOrThrow function.
This is what the snippet looks…

rickturner2001
- 57
- 7
0
votes
0 answers
Disable Zod for Specific Objects or Allow Arbitrary Values for Specific Objects?
I have a very large JS object I want to pass to trpc, through zod.
Right now I just want to play around with the object a bit, before creating my zod schema.
Is there a way to allow anything to be passed into zod (at least just in dev mode)? Or to…

antonwilhelm
- 5,768
- 4
- 19
- 45
0
votes
2 answers
tRPC mutateAsync returns nothing
This is my first attempt to use tRPC. I created a mutation named "add", which receive a URL as parameter and returns a hardcoded slug
Router
export const entryRouter = router({
add: publicProcedure
.input(input)
.output(output)
…

Rodrigo
- 135
- 4
- 45
- 107