tRPC

T

tRPC

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

Join

Nested tRPC procedures.

I'm trying to convert a REST API structure to tRPC. Specifically, I want to replicate the nested REST route products/:productId/discount in tRPC ? . How should I declare and organize these nested routes in tRPC to match this structure effectively?
Solution:
there is no reason for the nesting here because you only have one procedure inside the nested routers

tPRC ERROR on T3 stak

I just initialized a folder with the "T3 Stack". The stack is: - Next.js with typescript - Prisma as ORM with sqlite - tRPC...

How to add signal on mutateAsync?

const stream = await ask.mutateAsync(data);
const stream = await ask.mutateAsync(data);
i want to parse signal there...

Forward NextJs Request to TRPC Server

Hey everyone! I need some help with my project setup. Here's my current situation: My Setup: * I have a NextJS 14 project (which is both client-side and server-side) * I also have a separate ExpressJS tRPC server...
No description

ERROR TypeError: queryClient.getMutationDefaults is not a function (it is undefined)

```typescript const { mutate: joinChallenge } = api.challenges.join.useMutation(); const handleJoinChallenge = () => { }; joinChallenge({...

Guides on authoring own client like `@trpc/react`

Hello, are there plans or guides to create own client useQuery in @trpc/react? I'm asking this because I plan to create something for Svelte + Tanstack Svelte Query but looking at the source code for v11, the types are scattered all around and i cannot seem to follow. Also, there is 1. createRecursiveProxy 2. createTRPCClientProxy 3. createTRPCFlatProxy...

trpc useQuery/useMutation not inferring return type of prisma query

Env: Node18 , npm i'm using turborepo with the server as Honojs + hono-trpc adapter and the client as react vite So i've already did the setup as said in the docs and everything is working perfectly everything returned from the trpc procedures is inferred except when i return a prisma query then the inferred type is "any" ?? ...
Solution:
i solved it so it was an error with the context which contains (prisma and telegram bot) not being inferred from the client so i had to type it manually now all returned prisma queries works as expected...
No description

createTRPCReact call 3 time on error

I dont know why, i dont use "useEffect" fn on my page
No description

I commented my query out, but i still notice request are still been made. this is what my code look

I keep getting api request to backend continously even without making api request. my api client ```typescript import { useMemo, useCallback } from "react"; import Constants from "expo-constants"; import { useSupabaseClient } from "@supabase/auth-helpers-react";...

useQuery `onSuccess` callback depreciated

Hello. I've just found out that the onSuccess callback in useQuery has been depreciated. What should I be using instead? ```ts This callback will fire any time the query successfully fetches new data. @deprecated — This callback will be removed in the next major version....

Examples-next-formdata

https://github.com/trpc/examples-next-formdata I am using tRPC with an Express server and am trying to get formData to work with tRPC. From what I have read, it is now possible to do so. However, when I tried running the examples-next-formdata repository to better understand its implementation, it always fails with the following error: ```ts...

how are you meant to set up client side queries?

why is there no type on the data? don't know what to do about the deprecated onSuccess stuff either. ```tsx trpc.authCallback.useQuery(undefined, { onSuccess: ({success}) => {...
No description

how do I fix this

Solution:
thank you that worked!
No description

tRPC and playing audio files on the frontend

Hello all! Reaching out to the community here to see if anyone can help. I am putting together an audio player component for my electron app and use tRPC for all backend communication. Specifically I am using the electron tRPC setup (https://github.com/jsonnull/electron-trpc) I was wondering if anyone has used something like the react h5 audio player and served audio files to it using tRPC yet or should I just go with an express server setup?...

How to query with async/await

I'm trying to initialise my react context store on mount with data coming from trpc. I'm using the t3 stack right now, and it's not immediately obvious on how to wait for the data to load before setting it in the store.. I'm using zustand and he is a snippet of my code ```ts export const defaultInitState: State = {...

Prefetch | useSuspenseQuery | Error: redacted | updateDehydratedSuspenseComponent

I would like to know if there is any alternative for my requirements: 1) The page finishes loading, just render after all the prefetch that exist 2) If any of the prefetch returns some type of error, the component that depends on that prefetch will not render 3) Don't keep flooding Error: redacted in the server console as shown in the print...
No description

tRPC & Next.js confused about error

Hey, I'm really new with next.js, react and trpc, I was trying to add tRPC into my small SSR next.js project to send data from the client to the server, following the tRPC Next.js examples is pretty tricky knowing close to nothing about it and I am getting a weird error. It doesn't tell me where it is, what file, I've tried mostly commenting out code from my page.tsx file and I still get the useState error? I'm not sure how to set up layout.tsx too... That's probably what I'm doing wrong but I don't know where to find out what is wrong layout.tsx ```tsx import type { Metadata } from "next";...
Solution:
For context, trpc does not officially support Nextjs App router. Instead of wrapping your component in trpc's HoC, you can create a client component provider and wrap your app with it. Look here https://github.com/trpc/trpc/issues/3297#issuecomment-1423905894...
No description

Next's app router is slow when using server components, how to optimize?

it takes about 3-4s to redirect to another page that fetches data using server caller, how to solve this?

CORS Preflight did not succeed

I cannot seem to access my api endpoint but when I manually do it in the browser, it works. I attached images of the network tab and the code
Solution:
Fixed it by manually specifying each method instead of using ANY ..for context, I am using sst/ion for IaC...
No description

"Find all references" in VSCode not working

Node.js: 18.17.1 @trpc/server@10.45.2 @trpc/client@10.45.2 TypeScript: Version 4.7.4 ...