Day 2: Exploring tRPC — My First Steps Toward Type-Safe APIs

Previously on Day 1…
I explored Kinde Auth, a quick and easy way to setup Authentication — and it will be my go-to for MVPs or side projects.
I also learned about Eventual Consistency, a subtle but important concept I plan to keep in mind when using third-party auth services or webhooks. It’ll definitely help me debug smarter in the future.
Why tRPC caught my eye.
This came from a tutorial by Josh Tried Coding
Disclaimer I am new to this and am sharing real-time learning. I’ve always found backend-to-frontend communication a little fragile REST endpoints that break silently. So, when I heard tRPC as a fix-all for clean data flow, I had to investigate.
Enter tRPC: Type Safety Across the Wire
tRPC stands for Typescript Remote Procedural Call. In quintessential Next.js setup, when the backend sends data to the fronted, it’s often typed as any
type which isn’t safe and can lead to silent bugs. But with tRPC, you get automatic type safety. the exact types from your backend procedures are inferred on the frontend.
This was totally new to me — and honestly, kind of magical. It lets your frontend talk to your backend without manually writing API routes, and the TypeScript types just carry over like they were meant to be there.
🔄Without tRPC
const res = await fetch('/api/user')
const data = await res.json() // data is `any`
TypeScript has no idea what data
looks like unless we manually define types and keep them in sync across front and back which can get extremely tedious.
🔄 With tRPC
// backend
export const appRouter = router({
getUser: publicProcedure.query(() => {
return { id: '123', name: 'Aurélie' }
}),
});
// frontend
const { data } = trpc.getUser.useQuery();
// ✅ `data` is typed as { id: string; name: string }
Type safety is automatically inferred from backend to fronted, no schemas, no duplication.
Why I’ll Use tRPC From Now On
Automatic type inference across the wire
No need for API response interface or
zod
parsing (unless you want validation)Full-stack apps with tight frontend/backend integration (like admin dashboards, internal tools)
Resources
Have you used tRPC before? I’d love to hear how it worked for you — share your experience in the comments!
Thanks for reading and following along on Day 2. 🚀
Subscribe to my newsletter
Read articles from Aurélie directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
