T
tRPC

Multiple TRPC endpoints on same API, with discrete clients? Any gotchas?

Multiple TRPC endpoints on same API, with discrete clients? Any gotchas?

Nnikfp10/18/2023
I'm building a Sveltekit app that has several pages that will need to behave like SPA's. Rather than have one TRPC enpoint in the api routes, I'd like to divide each section of the app into it's own trpc server handler, and be able to call a discrete client for that portion. This would allow separation of concerns for each portion of the app. My plan is the following routes ( and maybe more as the app grows) - /routes/api/estimating/trpc/[...procedures] - /routes/api/scheduling/trpc/[...procedures] - /routes/api/reporting/trpc/[...procedures] On the client I would create a separate client for each server route pointed to the corresponding URL. This would in effect create 3 distinct standalone TRPC servers in the app. Any gotchas with this that anyone can see? Anyone done something like this?
DDxD10/18/2023
Why would you create more tRPC servers ? Why I u do not have just one server, that server has 1/2…n routes that can do several things ? I have one server and I created multiple routes for different things
Nnikfp10/18/2023
what I was hoping for was having the multiple routers isolated per API route, so when you were working on the estimating route you would only have access to the trpc procedures for that route. Just a level of isolation for development, so futures devs (ahem me) don't get confused and start cross cutting concerns. Also not sure if this holds water, but having separated routers might mean less load on the language server so I might be able to scale the project a bit more before trpc starts to bog down. All just conjecture at the moment, but I'm curious how folks are doing things.
DDxD10/18/2023
I belive trpc dealing very well the routes Also … nice try Good luck I am just a beginner with it So..go ahead
Nnikfp10/18/2023
I'm also kind of a beginner tbf, I used it for a little while just to see how it worked, and then started using form actions in Sveltekit when those came around. This was about a year ago, and I didn't get a ton of time with trpc. My biggest concern is committing to it, then finding out later that it's bogging down development earlier than I'm ready to start breaking the app apart into discrete services to get the perf gains. We'll see, all opinions on the matter are welcome.

Looking for more? Join the community!

T
tRPC

Multiple TRPC endpoints on same API, with discrete clients? Any gotchas?

Join Server
Recommended Posts
Proper way to revalidate SSR but from Client Side, ie. after a success Mutation.This question has been also posted on an specific thread but posting this here will allow people to How to implement tRPC auth ?Do you have any article/github links for how can i create auth in tRPC ?tRPC middleware infer type from another protectedProcedureHello, `protectedProcedure` check and adds a not nullable user to the ctx. However the `studyMiddlewtRPC requests on client vs server for NextJsHello, I'm new to tRPC, and am confused on one thing. I have watched videos of some using a server cpassing user input state variable to all api callsI have a multi organization app and need a way of passing the current organizationId on all requestsIs there a way to extract a procedure signature?I'm looking into extracting certain handlers into functions to keep certain procedures more manageabIs there a pattern for omitting certain types of errors from being returned in the API responseI'd prefer not to expose the ORM queries being used in my resolver. I'm already providing an `onErroDynamic input not leading to changes on the front endI'm building a dynamic procedure to access my database via Drizzle ORM. Ideally a developer would btRPC 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/rHello, is there any way to create a base router with common procedures? like an interfaceI want all routers that use it have the state procedure (subscriptions), so I can create a common hHelp Retrieving req.url from opts in useMutation from tRPCHello, i'm trying to essentially send a magiclink email using supabase client libraries, however, i'Express tRPC NextJSI've custom expressjs server with Nextjs + im using internal package for handling OneLogin (OIDC) hoDynamic 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 cancalling TRPCProxyClient from inside trpc procedure fails on vercel route handlers edge runtimei setup my client as following: ``` export const serverToServerApi = createTRPCProxyClient<AppRouterPrivate procedures and serverside callsHello, I am just diving into trpc in my Next.js (app router) application and I am wondering if is thinferRouterOutputs 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 commentsHow can i modify my URL using TRPCI did a simple pagination in react and trpc(a simple table), only problem is that: i want in my url TRPC EXPORT API TYPES BE to FEIs there a way I can automatically export my API types from the backend to the frontend? For examplehow to access body in middlewareHi, I’m using trpc with nextjs. Does anyone know how to access the request’s body in middleware? As Decreasing autocomplete performanceAnyone else suffering from increased latency (mostly on the front-end) when doing autocomplete with