ker4lis
TTCTheo's Typesafe Cult
•Created by ker4lis on 12/17/2023 in #questions
tRPC differentiate server and client requests
How does tRPC differentiate between calls made from a server component and client component in T3 app, and subsequently only create an API request when on the client.
I am wondering because mostly for my app I’ll only send API requests to tRPC from the client related with auth. And I am not sure if using tRPC has any advantages for my use case. I am gonna be fetching data from the database in the app, but that will only be through server components so I am not sure if tRPC would even have a use here since I can just do it directly in the server component and wouldn’t necessarily need an API for that.
Also if using tRPC ends up being the best solution, would it be advisable to separate the RPC endpoint into for example api/trpc/auth and api/trpc/app etc… or is that completely unnecessary. I have mostly experience with Rest APIs and I know that RPC is supposed to create a single endpoint solution, but for broader categories I am still wondering if there is a use for seperation.
Thank you for any help :)
1 replies