tRPC

T

tRPC

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

Join

Is there a way to extract a procedure signature?

I'm looking into extracting certain handlers into functions to keep certain procedures more manageable. Is there a way to define a function that expects the same signature as a procedure? Here's an example of what I'm trying to achieve....
No description

Is there a pattern for omitting certain types of errors from being returned in the API response

I'd prefer not to expose the ORM queries being used in my resolver. I'm already providing an onError function to send these errors to Sentry, but I can't figure out from the docs how to actually change the error message returned to the API caller.
No description

Dynamic input not leading to changes on the front end

I'm building a dynamic procedure to access my database via Drizzle ORM. Ideally a developer would be able to send input parameters to the procedure and have it's output adjusted by that input. For example, in the below, I have a table called demotable which has an updatedAt column. If a developer passes in columns: { updatedAt: false } to the procedure, then ideally the column would not get included in the result....

tRPC with with react-query prefetching in Next.js app directory.

Hi. What is currently the best way to do prefetching in Next.js app directory when using @tanstack/react-query and Next.js app directories?

Hello, is there any way to create a base router with common procedures? like an interface

I want all routers that use it have the state procedure (subscriptions), so I can create a common hook later Although the implementation of the methods is completely different on each router, I just want to guarantee that they have those procedures, like an interface The hook basically will subscribe to the state on mount, and unsubscribe on unmount...

Help Retrieving req.url from opts in useMutation from tRPC

Hello, i'm trying to essentially send a magiclink email using supabase client libraries, however, i'm running into an issue of not being able to retrieve the req.url (in order to get the baseURL). I would prefer not to hard-code it due to changing addresses between localhost, Vercel Preview Branches, Primary Domain. Code Context ```ts export const authRouter = router({...
Solution:
I just figured it out, it was my lack of understanding that the fetchRouterHandler was meant for edge runtimes, and I had to change my createContext function to FetchCreateContextFnOptions change my trpc route handler appropriatly for the fetchRouter: /app/api/trpc/[trpc]/route.ts ```ts import { fetchRequestHandler } from "@trpc/server/adapters/fetch"; import { appRouter } from "@/api-server";...

Express tRPC NextJS

I've custom expressjs server with Nextjs + im using internal package for handling OneLogin (OIDC) hooked as express middleware which runs. before the Nextjs trpc. I encounter a problem where I do fire a request api call via trpc query or mutation and the OIDC middleware catches that the request is 401 trpc throws on me that TRPCClientError: Unexpected token 'U', "Unauthorized" is not valid JSON if I change the response of the middleware as a json instead of text something like ```...

Dynamic links url dependent on next headers?

Hi, We're currently explore if we can use trpc on a multi tenant next.js 13 application. But we can not find a satisfying answer how to set the url for the links used in createTRPCProxyClient ...

calling TRPCProxyClient from inside trpc procedure fails on vercel route handlers edge runtime

i setup my client as following: ``` export const serverToServerApi = createTRPCProxyClient<AppRouter>({ transformer, links: [...

Private procedures and serverside calls

Hello, I am just diving into trpc in my Next.js (app router) application and I am wondering if is there any example repository where I can take a look how is implemented private procedure (requires authenticated user - next.js) which is called from client component and also loaded from server component or if is there any best practise how to deal with this scenario? Thank you for any responses...

inferRouterOutputs ignore "complex data type" fields and only have primitive fields. Bug?

Is this a bug ? I have done npx prisma db push, I have restarted VSCode and Typescript. Any comments would be appreciated thanks 🙂
No description

How can i modify my URL using TRPC

I did a simple pagination in react and trpc(a simple table), only problem is that: i want in my url to show page and limit whenever i modify it(like this .../human-resource/employee&limit=2&skip=5) How can i do this ?...

TRPC EXPORT API TYPES BE to FE

Is there a way I can automatically export my API types from the backend to the frontend? For example, after I modify my backend (e.g., create a new route), do I need to run something like 'trpc-api-export,' and will everything generated in my 'dist' folder be copied and placed in the 'api/api-types' folder on the frontend? Is there an automated way to do this?

how to access body in middleware

Hi, I’m using trpc with nextjs. Does anyone know how to access the request’s body in middleware? As per the Request docs, the body can only be accessed once via await req.json(). However, if I do that in the middleware, the body is unusable within the trpc procedure.

Decreasing autocomplete performance

Anyone else suffering from increased latency (mostly on the front-end) when doing autocomplete with T3 stack? How did you solve it, seperate root routers? More routers (some of mine are >1k lines)?...

Error while creating a mutation in NextJS

I am having the following error:
"message": "No \"query\"-procedure on path \"checkout.stripe\"",
"code": -32004,
"message": "No \"query\"-procedure on path \"checkout.stripe\"",
"code": -32004,
Here is my code: ...

trpc Pagination

Does somebody have any example how can i do pagination in trpc and react query?

Auth through trpc procedures

Has Anyone Successfully Implemented Supabase Auth through tRPC Procedures in a Next.js App? Hello everyone 👋, I'm currently working on a Next.js project and trying to handle authentication using Supabase and tRPC. While I've been able to perform authentication directly via the Supabase client, I'm running into some issues when attempting to do the same through tRPC procedures. Specifically, sessions are not being added to cookies....

supabase + trpc

did anyone handle to make it work -> context and all signup signin etc methods?