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
trpc is just a typesafe client
if you can get the correct types from trpc and a valid url
should work regarldess of the backend
but how does it work though? how would it provide type-safety between the frontend and backend?
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
you can you import type if frontend and backend are separated?
must it be a monorepo then?
monorepo or publishing the types
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