MadaShindeInai11mo ago

tRPC in Next without api rotes

Hello! I have NextJS app that gets data in gSP using some third-party client. This data comes untyped, and i'm thinking if tRPC can help me to manage this behavior in a better way, than just zod validation. One more thing - i do not want to make some public endpoint for quering this data. But I can't find any examples of tRPC usage in NextJS without API routes. Does it mean that tRPC do not fit my task as it actually "a gates of BE part"?
1 Reply
josh_bee11mo ago
When next builds you still get a client and server so there has to be a way to talk between the two over the web. Regardless of which solution you go with you will need to use API routes or some other method to reach the server so this isn't just a problem with tRPC. You are probably best of creating some type of api key / middleware which will reject unauthenticated requests.