Have you ever updated your backend API property name but neglected to update the frontend as well? I believe you have. When this happens, it leads to production crashes and unhappy customers, plus you’ve wasted your entire week fixing the problem.
To solve this problem in the past, you usually had to generate a bunch of TypeScript interfaces by hand, using a GraphQL code generator to generate the interface files, or hope it all worked out. Well, now there’s a better way to accomplish this, without the need for code generation.
trpc And be There are two applications that are changing how we develop TypeScript-based applications across the full stack.
By the end of this tutorial, you will understand:
Why Traditional REST APIs Fail Type Safety
How TRPC provides complete end-to-end visibility between backend and frontend
How Hino Provides a Type-Safe API While Remaining Relax-Friendly
When you choose TRPC vs Hanu for your projects
How these tools improve developer experience, team speed and reliability
If you’re building full-stack TypeScript applications and want fewer runtime bugs and faster iteration, this guide is for you.
Table of Contents
Conditions
To comfortably follow along, you should:
Basic knowledge of Typescript
Familiarity with REST APIs and how front-end back-to-back communication works
Some experience with Node.js and modern JavaScript frameworks
General understanding of front-end frameworks such as React or Next.js (helpful, but not required)
You do not need prior experience with TRPC, Hono, or GraphQL.
The problem with traditional APIs
You’ve probably written something like this a hundred times:
app.post('/api/users', (req, res) => {
const { name, email } = req.body;
res.json({ id: 1, name, email });
});
const createUser = async (name: string, email: string) => {
const response = await fetch('/api/users', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name, email })
});
return response.json();
};
The backend knows the format of the data. But the front end … he hopes it will be fine. You end up writing the interface manually, like:
interface User {
id: number;
name: string;
email: string;
}
If you change background to come back tomorrow userId Instead idtypescript won’t catch it. Your types and reality are reversed, and you won’t know until runtime.
Graph QL Tried to solve this with schematics and codegen, but honestly? Setting up GraphQL feels like assembling IKEA furniture without instructions. You need a schema, resolvers, code generation tools, and suddenly your “simple” API has a 30-minute setup process.
What makes TRPC different?
TRPC completely flips the script. Instead of defining your API in a separate schema language, your TypeScript code is the schema. Here is the same API in TRPC:
import { initTRPC } from '@trpc/server';
import { z } from 'zod';
const t = initTRPC.create();
export const appRouter = t.router({
createUser: t.procedure
.input(z.object({
name: z.string(),
email: z.string().email(),
}))
.mutation(({ input }) => {
return { id: 1, name: input.name, email: input.email };
}),
});
export type AppRouter = typeof appRouter;
This is where it gets cold. On your front:
import { createTRPCClient } from '@trpc/client';
import type { AppRouter } from './server';
const client = createTRPCClient({
url: 'http://localhost:3000/trpc',
});
const user = await client.createUser.mutate({
name: 'Alice',
email: 'alice@example.com'
});
No code generation or build phase, or GraphQL schema. Just a pure Typescript guess talking about it. If you change the name id to userId In your backend, your frontend will immediately show the typescript error. You’ll catch the file before you save it.
That’s what we call end-to-end security, and it’s honestly a huge transition.
Hono: Lightweight Challenger
While TRPC is amazing for full-stack TypeScript apps where you control both ends, be takes a slightly different approach. It is a lightweight web framework that gives you type safety while still being a traditional HTTP framework.
Here is a similar example in Hono:
import { Hono } from 'hono';
import { z } from 'zod';
import { zValidator } from '@hono/zod-validator';
const app = new Hono();
const userSchema = z.object({
name: z.string(),
email: z.string().email(),
});
app.post('/api/users', zValidator('json', userSchema), (c) => {
const { name, email } = c.req.valid('json');
return c.json({ id: 1, name, email });
});
export type AppType = typeof app;
On the front end, you can use Hono’s RPC client:
import { hc } from 'hono/client';
import type { AppType } from './server';
const client = hc('http://localhost:3000');
const response = await client.api.users.$post({
json: { name: 'Bob', email: 'bob@example.com' }
});
const user = await response.json();
Hono is incredibly fast (it runs on CloudFlyerWorkers, Dino, Bin, and Node.js), and it gives you a sweet kind of security while still being a “regular” HTTP framework. You get comfortable paths, middleware and all the familiar patterns – only with TypeScript powers.
Why does it matter these days?
You might be thinking to yourself, “Okay, I know what you mean, but why should I care?” There’s a reason why these tools are being used more than ever.
Developer experience is a must
From 2026 and beyond, we will no longer accept long feedback loops. The ability to modify your back-end code and see what might break your front-end application without running the application would be fantastic for productivity. We’ll spend less time fixing bugs and more time building new features.
Smaller teams, better apps
With TRPC or Hono, a developer can build a full-stack application with type safety at a very high speed because they don’t need to switch back and forth between REST documents and the TypeScript interface—all data is flowing directly from their backend code to their frontend.
End of “Work on my machine”.
With type safety, errors are caught at compile time instead of when your end user clicks a button. This is especially effective when working in large teams, when backend developers and frontend developers cannot be in constant contact with each other.
to begin
Want to try it? Here’s the fastest way:
For TRPC:
npm create @trpc/next-app@latest
This TRPC supports a Next.js app with an already configured TRPC. check Official TRPC documents for more.
For Hono:
npm create hono@latest
Choose your runtime (Node.js, CloudFlyerWorkers, etc.), and you’re off to the races. Hono documents Excellent and very accessible.
Future is type-safe
Look, relaxation isn’t going anywhere, and GraphQL has its place. But for full-stack TypeScript developers, TRPC and Hono represent something special: type safety without function. No code generation or no schema replication, just Typescript that does it best.
In the future, when you start a new project, give one of these a shot. Your future self — the one refactoring code at 2 a.m. — will thank you.
Happy coding!