should I share TRPC client in a internal package?

I have 2 clients and 1 server in one monorepo. these 2 clients are consuming the same api/using the same trpc. both are doing the same, having a file just to crate the TRPC on the app by following this code: export const trpc = createTRPCReact<AppRouter>(); is right to share it in a internal package?
1 Reply
Sean Cassiere
Sean Cassiere2y ago
It's best to export the formed appRouter (plus its typings) and the createContext function. Then, in the server, import the appRouter and the createContext fn, and create the trpc instance on the server. And on the client apps, import the typings for AppRouter and create the trpc-react-query client-api to call the endpoint on the server. The create-t3-turbo repo, is a great reference for this: https://github.com/t3-oss/create-t3-turbo/
GitHub
GitHub - t3-oss/create-t3-turbo: Clean and simple starter repo usin...
Clean and simple starter repo using the T3 Stack along with Expo React Native - GitHub - t3-oss/create-t3-turbo: Clean and simple starter repo using the T3 Stack along with Expo React Native
Want results from more Discord servers?
Add your server