00000
000004w ago

how can I set up trpc to work with nested providers?

Hi, I have two separate clients with their own typings and HTTP links, and I wrap my application in nested providers—one for each client—with their own QueryClient instances. However, regardless of which client I use, the runtime always sends the request to the URL specified in the innermost provider. The typings and client definitions appear correct, but at runtime both clients' queries are routed to the endpoint of the innermost provider. Any help would be greatly appreciated!
No description
2 Replies
tenzerino
tenzerino2w ago
Seems to be similar to https://github.com/trpc/trpc/discussions/6685. In theory this should be possible, as this has been implemented by this pr, although I'm not sure if your setup is correct. There is a test for multiple trpc providers for @trpc/react-query, where you could look at the setup and if it is implementable in your app.
Nick
Nick2w ago
The recommended approach would be SOA which we have an example for: https://github.com/trpc/trpc/tree/main/examples/soa
GitHub
trpc/examples/soa at main · trpc/trpc
🧙‍♀️ Move Fast and Break Nothing. End-to-end typesafe APIs made easy. - trpc/trpc

Did you find this page helpful?