tRPC

T

tRPC

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

Join

Response promise resolves before endpoint finished processing

I want to interact with OpenAI's API in my Next.js + tRPC app. It seems that the my frontend is not waiting for the backend to finish the API call before using the response, leading to an error because the response is still undefined. This is my endpoint: ```typescript export const llmRouter = createTRPCRouter({...

tRPC onError

I am using tRPC with Fastify and would like to be able to report issues when we get an error. https://trpc.io/docs/server/error-handling#handling-errors It mentions we have a onError function, but I only see it inside: ...

Code structure for a large monorepo using nx + tRPC

We have a large monorepo with a single tRPC API that will be used by several web clients and other consumers. We use nx for our build system. We want a way to share the API contract between client and api, but we don’t want implementation changes that do not change the API contract to trigger a rebuild of all the clients and consumers. Ideally we’d also want to have our api split into several routers and have some applications only rely on a subset of the routers....

Does tRPC work with Clerk and Vercel Edge functions?

So the answer is yes, at least locally, but I when I deploy to Vercel I get nothing. Trying to work out whether this is happening at the tRPC, Clerk, Vercel, or Planetscale integration level. Anyone experiences something similar?
Solution:
So the answer is yes, at least locally, but I when I deploy to Vercel I get nothing. Trying to work out whether this is happening at the tRPC, Clerk, Vercel, or Planetscale integration level. Anyone experiences something similar?

TRPCClientError when creating a db entry without `updatedAt` value?

Guys, this is my prisma schema: ``` model User { id Int @id @default(autoincrement()) firstName String?...
Solution:
this is a prisma question not a trpc one. based on the error sounds like you need to provide a value for updatedAt

Type error: The inferred type of 'trpc' cannot be named without a reference....

./src/lib/api.ts:21:14
@driveorg/dashboard:build: Type error: The inferred type of 'trpc' cannot be named without a reference to '.pnpm/@trpc+react-query@10.26.0_@tanstack+react-query@4.28.0_@trpc+client@10.26.0_@trpc+server@10.2_ssrxcmysrtuzb43rctcerwnzbe/node_modules/@trpc/react-query/shared'. This is likely not portable. A type annotation is necessary.
./src/lib/api.ts:21:14
@driveorg/dashboard:build: Type error: The inferred type of 'trpc' cannot be named without a reference to '.pnpm/@trpc+react-query@10.26.0_@tanstack+react-query@4.28.0_@trpc+client@10.26.0_@trpc+server@10.2_ssrxcmysrtuzb43rctcerwnzbe/node_modules/@trpc/react-query/shared'. This is likely not portable. A type annotation is necessary.
...
No description

Decision on auth

I am using create-t3-app for my app , with next-auth (twitter, discord, google) . Now i am using same api for my react-native client. Now how can i authenticate users from my react-native app???...

Senior Full Stack Developer is Ready.

✍️ Skill Set HTML/CSS/JS, TS React/Next.js, Angular/RxJs, Tailwind CSS WordPress/Laravel/CI Blockchain/Smart Contract/Solidity...

How to pass context to vanilla client?

Hi, I have a next app where I use trpc. Now I need to call some trpc functions from outside of any components. My first solution was to just call the endpoint with axios. `...

Is this blog correct? Trpc and next.js 13.4, App directory

I working on integrating with TRPC with the App directory and was given a solution but i'm not sure if the author or myself have the right understanding of how server components work with client components. The scenario: By adding the ‘use client’ directive in the route app layout file which the author suggests, wouldn't that mean all children components would become client-side components, so we would loose the benefits of server components? ...

Is there a way to transform data server-side only?

I'd like to implement something like Symfonys ParamConverter that converts certain params, but server-side only, so that I can use Prisma and alike. Couldn't figure out how to use data transformers for this use case

How do I prefetch the nextPage of an infiniteQuery?

I have a custom infiniteQuery hook, and I want to prefetch the next page on success. My current implementation is this: ```ts onSuccess(data) { const cursor = data.pages.[data.pages ?.length - 1]?.nextCursor console.log(cursor)...

is it possible to use trpc on next js api routes

like can i use trpc mutation or query on /api/test

Dockerfile in Tubrorepo

Hi I have a Turborepo where I have a nextjs frontend “web” and an express backend “api” both connected through trpc (guess that’s obv). I’m kinda finding it difficult to create a docker image for this 🫠 has anybody else done this before? Any example I could take a look at? Thanks!

Querying external api in trpc router not working

Hi guys! So I'm trying to query an api endpoint that I created through a separate node server inside my trpc router, I'm fetching it using axios but it does not work at the moment. I can't seem to figure out why.

[HOW TO?] Call trpc endpoints from vanilla nextJs api routes

Spinoff from an og thread here: https://discordapp.com/channels/867764511159091230/1032301198990135347 HI! I am wanting to do the same thing...call a trpc route from within a nextjs public api endpoint. ...

Tutorial for setting up tRPC with Next13 app dir?

Anyone has a goos tutorial (blogpost / YouTube) on setting up tRPC with Next13 app dir for both client components as well as server components? I have tried for the entire day and couldn't find a way to make it work... :/...

Stack trace in Client?

I've just found that in production I can see stack trace for TRPCErrors. Isin't it supposed to not show it? Checking on development build with isDev for initTRPC doesn't seem to work at all. I've set it to false but I can see still stack trace too. Also is it good idea to have loggerLink enabled in production?...

Sequential batch mutation

How one would make a mutation as a sequential mutation batch call? Say I have to add 10 apples to the basket. My API allows only to add one at a time so I need to make 10 mutations one after another plus I would need to catch which one succeeded and which failed....