Go source of truth
Register typed Go queries, mutations, and SSE subscriptions from your handlers and structs.
Build your API in Go and call it from TypeScript with tRPC clients. trpcgo serves your handlers over the tRPC HTTP protocol and generates frontend types from your Go structs, so you can use @trpc/client, @trpc/react-query, or @trpc/tanstack-react-query.
Go source of truth
Register typed Go queries, mutations, and SSE subscriptions from your handlers and structs.
TypeScript tRPC clients
Generate an AppRouter type that works with tRPC clients and React Query integrations.
Validation schemas
Generate Zod input schemas from Go validate tags for client-side form validation.
Plain HTTP runtime
Serve procedures from a net/http handler with batching, SSE, middleware, and error formatting.
Source analysis
Use go tool trpcgo generate to include comments, const unions, enum values, aliases, generics, and validation tags.
Automatic regeneration
In dev mode, update frontend types and schemas when you save Go files.
Register procedures in Go, generate the TypeScript router type, then call the API from the same tRPC clients you already use.
router := trpcgo.NewRouter( trpcgo.WithDev(true), trpcgo.WithValidator(validate.Struct), trpcgo.WithTypeOutput("../web/gen/trpc.ts"), trpcgo.WithZodOutput("../web/gen/zod.ts"), trpcgo.WithEnumsOutput("../web/gen/enums.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"))With these dev options, creating the HTTP handler generates the frontend files and starts a watcher. Restart the Go server when you change handler behavior. Quick Start includes the imports, validator setup, and server startup code.
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' });Follow Quick Start to build your first endpoint, or read Core Concepts to see how procedures, routers, and code generation fit together.