tRPCttRPC
Powered by
nikfpN
tRPC•3y ago•
11 replies
nikfp

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

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/estimating/trpc/[...procedures]

-
/routes/api/scheduling/trpc/[...procedures]
/routes/api/scheduling/trpc/[...procedures]

-
/routes/api/reporting/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?
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

Multiple Clients/Services In tRPC Context
isaac_wayIisaac_way / ❓-help
4y ago
Call multiple TRPC endpoints from onSuccess()?
peternovakPpeternovak / ❓-help
3y ago
TRPC ratelimiting endpoints
rustclanRrustclan / ❓-help
3y ago
calling api endpoints from within a trpc api endpoint?
rustclanRrustclan / ❓-help
4y ago