I am a Dev
I am a Devโ€ข10mo ago

In a monorepo can I have 2 packages each one with different trpc server, and use both in 1 app?

I want to create 2 different APIs, and in my monorepo I have several apps, in some I want to use both, in others only 1 Thanks
3 Replies
21Vicโ€ข10mo ago
Hey @I am a Dev I personally haven't tried this but it seems to me this is perfectly fine! You'd want to do this, https://trpc.io/docs/client/vanilla/setup for each API you want to use. Let's say you have API #1, and API #2. Then in App #1 you want to use both, you'd import the AppRouter type from both API#1 and API#2 and run the corresponding setup for each. Then say in App#2 you only want to use API#2, you'd only do it for that one. I'd also imagine you can get rid of some of the client setup redundancies across apps if you setup a shared package that sets up a client for each API and then the clients can be shared amongst your other apps and used as needed!
Set up a tRPC Client | tRPC
1. Install the tRPC Client library
Alex / KATT ๐Ÿฑ
Alex / KATT ๐Ÿฑโ€ข10mo ago
trpc/examples/soa at main ยท trpc/trpc
๐Ÿง™โ€โ™€๏ธ Move Fast and Break Nothing. End-to-end typesafe APIs made easy. - trpc/trpc
Alex / KATT ๐Ÿฑ
Alex / KATT ๐Ÿฑโ€ข10mo ago
if you want the apis deployed separately but glue them together in the client you can use this approach