Weird tech stack from coding assignment

I just got a coding assignment that ask me to use Next.js with Fastify (backend) and tRPC. As I understand it, tRPC uses typescript to connect the frontend and the backend. I've used tRPC in Next.js as the frontend and backend. But how exactly does tRPC work when the frontend and backend are separated? Is my understanding of tRPC wrong? Wouldn't fontend and backend need to be in the repository for tRPC & typescript to work?
8 Replies
Neto
Neto2mo ago
trpc is just a typesafe client
Neto
Neto2mo ago
if you can get the correct types from trpc and a valid url should work regarldess of the backend
Luc Ledo
Luc LedoOP2mo ago
but how does it work though? how would it provide type-safety between the frontend and backend?
Neto
Neto2mo ago
for ts backends, if you can import the type correctly, trpc should be able to deal with the rest on the frontend for non-ts backends, openapi or graphql
Luc Ledo
Luc LedoOP2mo ago
you can you import type if frontend and backend are separated? must it be a monorepo then?
Neto
Neto2mo ago
monorepo or publishing the types
cje
cje2mo ago
It can even just be a git repo with two folders in it The “type safety” in tRPC is just importing backend types in the frontend So the client knows what to request and expect in response
Want results from more Discord servers?
Add your server