Implementing Real-Time tRPC Subscriptions with WebSocket in Next.js 14+
Set up a type-safe WebSocket subscription in Next.js 14+ with tRPC, enabling instant data sync between server and React client.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Set up a type-safe WebSocket subscription in Next.js 14+ with tRPC, enabling instant data sync between server and React client.
tRPC removes separate API schemas by exporting your server router type to the client. See a protected-procedure example with Zod and context, plus the coupling limits that matter for third-party consumers.
tRPC v10 with createTRPCReact and httpBatchLink lets React call backend procedures with full TypeScript inference. Define an AppRouter on the server, type the client to it, and use inferred useQuery/useMutation hooks.
tRPC’s initTRPC lets you build reusable authentication middleware and a request‑scoped context. This guide shows how to create public and protected procedure builders, merge routers, and handle auth errors—all while keeping TypeScript types intact.
Learn how to eliminate repetitive authentication boilerplate in tRPC by implementing Protected Procedures and Middleware for type-safe API security.
Use tRPC’s React Query integration to let the client infer input and output types from the server router. The guide shows a minimal setup, explains how batching and transformers work, and lists common pitfalls and limits.
tRPC normally turns Dates into strings and drops undefined values when serializing JSON. Using a data transformer like superjson preserves rich JavaScript types, keeping your TypeScript types accurate from server to client. This post shows how to set it up, tests to verify, and the trade‑offs.
Choose how to share tRPC Router types between server and client. Compare monorepo instant sync versus separate packages with versioning, trade‑offs, and validation steps for end‑to‑end type safety.
Learn how tRPC and Zod eliminate the 'out-of-sync' API bug by merging runtime validation with compile-time type safety, removing the need for manual API interfaces.