Go API server
Register typed Go queries, mutations, and SSE subscriptions on a plain net/http handler.
trpcgo is for teams that want the tRPC developer experience without running the API server in TypeScript.
Your Go handlers and structs are the source of truth. trpcgo serves them over the tRPC HTTP protocol and generates the TypeScript AppRouter type that @trpc/client, @trpc/react-query, and @trpc/tanstack-react-query understand.
Go API server
Register typed Go queries, mutations, and SSE subscriptions on a plain net/http handler.
Typed frontend
Generate a structural AppRouter contract so TypeScript catches broken procedure calls.
Validation schemas
Generate Zod input schemas from Go validate tags for client-side form validation.
Runtime controls
Configure batching, strict JSON decoding, body limits, SSE limits, context, middleware, and error formatting.
Source analysis
Use trpcgo generate to preserve comments, const unions, aliases, generics, and validation metadata.
Dev watch
In dev mode, regenerate frontend files on Go file changes without restarting the server.
router := trpcgo.NewRouter( trpcgo.WithValidator(validate.Struct), trpcgo.WithTypeOutput("../web/gen/trpc.ts"), trpcgo.WithZodOutput("../web/gen/zod.ts"),)defer router.Close()
trpcgo.MustQuery(router, "user.get", getUser)trpcgo.MustMutation(router, "user.create", createUser)
mux := http.NewServeMux()mux.Handle("/trpc/", trpc.NewHandler(router, "/trpc"))import { createTRPCClient, httpBatchLink } from '@trpc/client';import type { AppRouter } from './gen/trpc.js';
const client = createTRPCClient<AppRouter>({ links: [httpBatchLink({ url: '/trpc' })],});
const user = await client.user.get.query({ id: '1' });Read Core Concepts to understand the runtime model, then follow Quick Start to build the first endpoint.