惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Martin Fowler
Martin Fowler
雷峰网
雷峰网
IT之家
IT之家
小众软件
小众软件
M
MIT News - Artificial intelligence
博客园 - 聂微东
J
Java Code Geeks
Blog — PlanetScale
Blog — PlanetScale
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
A
About on SuperTechFans
G
Google Developers Blog
Engineering at Meta
Engineering at Meta
Recent Announcements
Recent Announcements
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The GitHub Blog
The GitHub Blog
F
Fortinet All Blogs
C
Check Point Blog
云风的 BLOG
云风的 BLOG
腾讯CDC
H
Help Net Security
Y
Y Combinator Blog
I
InfoQ

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
tRPC: The End of API Docs as We Know Them
蔡俊鹏 · 2026-05-27 · via DEV Community

What's the Big Deal?

tRPC stands for TypeScript Remote Procedure Call. The pitch is simple: instead of writing REST endpoints, writing OpenAPI specs, generating TypeScript types from those specs, then manually keeping all that in sync — you just write TypeScript functions on the server. tRPC makes them callable from the frontend with full type inference.

No code generation. No duplicating schemas. Your backend code is the API.

Here's what that actually looks like:

// server/router.ts
export const appRouter = t.router({
  getUserById: t.procedure
    .input(z.string())
    .query(({ input }) => {
      return db.user.findUnique({ where: { id: input } });
    }),
});

// client/UserProfile.tsx
const user = trpc.getUserById.useQuery("user_123");
// user.data has the Prisma User type — you didn't write a single type annotation

Look at what's not there. No URL paths, no HTTP methods, no duplicating your types on both sides. Change the backend return and your IDE finds every broken frontend reference before you hit save.

tRPC v11: What Actually Changed

V11 has been stable since early 2026. If you're still on v10, here's what you get:

React Query v5 Integration

This is the biggest one. V11 requires React Query v5, which means Suspense support is baked in:

function UserProfile({ userId }: { userId: string }) {
  const [user] = trpc.user.get.useSuspenseQuery({ id: userId });
  return <h1>{user.name}</h1>;
}

No isLoading checks. No data?.name everywhere. Wrap it in Suspense + ErrorBoundary and you get clean, declarative data fetching.

SSE Subscriptions

V10 locked you into WebSocket for real-time features. V11 adds Server-Sent Events via the httpSubscription link, which means live chat, dashboards, and notifications without managing WebSocket connections. Also works with serverless platforms like Vercel and Cloudflare — which WebSocket never handled well.

File Uploads (Finally)

V11 handles FormData, Blob, File, and Uint8Array natively. If you've been splitting your project into "tRPC for queries" and "separate REST endpoint for uploads" — that workaround is dead. Everything goes through the same layer now.

Lazy-Loaded Routers

Big projects used to pay the bundle cost for all routers upfront. V11 supports code-splitting at the router level:

const adminRouter = () => import('./routers/admin');
// Only loads when admin feature is accessed

Where tRPC Actually Wins

After building with tRPC for about a year, here's where it genuinely makes sense:

TypeScript monorepos. If your frontend and backend share a repo — which they do with Next.js, SvelteKit, Remix — tRPC eliminates the type boundary. There's no "frontend types" vs "backend types." It's just types.

Internal tools. Speed beats discoverability here. You're iterating fast, changing endpoints constantly, and the whole team knows TypeScript. tRPC matches how you actually work.

Server-first frameworks. tRPC with Next.js App Router or SvelteKit server load functions gives you type safety from the database query straight to your React component. Hard to beat that developer experience.

Where tRPC Falls Short

Look, tRPC isn't here to kill REST or GraphQL. Anyone telling you otherwise is overselling it.

Public APIs are a bad fit. If mobile apps or third-party services need to call your API, tRPC isn't the right tool. It only works with TypeScript clients that import your router types. Non-TypeScript consumers? Can't use it.

Polyglot teams. If your backend has Python, Go, or Rust services alongside TypeScript, tRPC doesn't help. It's TypeScript end-to-end or nothing.

Heavy caching. REST has built-in HTTP caching (ETag, conditional GETs, CDN-friendly URLs) that tRPC can't match. If caching is your main concern, REST still wins.

The Practical Bottom Line

I built the same CRUD app with tRPC, REST + Zod, and GraphQL to compare. Response times were within 10-15% of each other for simple queries. The real difference? Over three weeks of active development, tRPC had zero type mismatches. REST+Zod had two. GraphQL had one (caught by codegen). Tiny sample, but it lines up with my broader experience.

REST still rules for public APIs. GraphQL still wins when clients need flexible queries. tRPC wins when you're all-in on TypeScript and want the fastest possible feedback loop.

Should You Use tRPC in 2026?

If your next project is a TypeScript monorepo — a Next.js SaaS, an internal dashboard, a SvelteKit app — yes. V11 is mature. The ecosystem is stable. You'll save real time not maintaining a separate type layer. You can always add a REST or OpenAPI layer on top later.

If you're building a public API or serving non-TypeScript clients, stick with REST or GraphQL. You're not missing anything.

The thing about tRPC is this: it doesn't replace API design. It removes the translation layer between your backend and frontend. For teams already living in TypeScript, that removal is worth more than I thought before I tried it.


This article is based on my original post at auraimagai.com, where I write about TypeScript, full-stack development, and tools that actually change how you build.