Is it possible to use trpc client in a shared monorepo package?
My pnpm monorepo setup:
- API (express)
- packages/shared (shared code)
- web (nextjs)
- app (react native)
right now my web uses trpc + react query for api calls. I want to add the same functinoality to the app, but dont want to have to repeat all of my react query hooks
ex.
I currently have to repeat this function in both web and mobile.
I wanted to move my trpc hooks to the shared package, but I keep getting error
i believe this is due to the fact that the package has to compile into declaration files and doesnt work with the approuter
is it not possible for me to share this API access layer? How do apps typically handle sharing TRPC code between mobile and web?

1 Reply
This generally shouldn’t happen, but you should be able to fix this just by importing @trpc/server into that file
It’s a common problem when exporting types which depend on another package (in this case client and server)