Install
trpcgo includes a Go runtime for serving procedures and a generator for frontend types and schemas. You’ll need Go 1.26 or newer.
Add The Runtime
Section titled “Add The Runtime”Run this in an existing Go module. For a new project, create one first with go mod init example.com/myapp.
go get github.com/befabri/trpcgo@latestImport the runtime and HTTP protocol handler separately:
import ( "github.com/befabri/trpcgo" "github.com/befabri/trpcgo/trpc")Add The Generator
Section titled “Add The Generator”Add the generator to your module’s tool dependencies:
go get -tool github.com/befabri/trpcgo/cmd/trpcgo@latestThis adds a tool directive to go.mod:
tool github.com/befabri/trpcgo/cmd/trpcgoThen run it with go tool:
mkdir -p web/gengo tool trpcgo generate -o web/gen/trpc.ts --zod web/gen/zod.ts ./...Create output directories first; the CLI does not create missing parent directories.
The generator looks for procedure registrations in the selected Go packages. If you haven’t written any yet, continue with Quick Start.
Frontend Packages
Section titled “Frontend Packages”Install the tRPC client packages used by your frontend framework. For a vanilla client:
npm install @trpc/client@11 @trpc/server@11For React Query:
npm install @trpc/client@11 @trpc/server@11 @trpc/react-query@11 @tanstack/react-query@5For the TanStack React Query helper API shown in Frontend Setup:
npm install @trpc/client@11 @trpc/server@11 @trpc/tanstack-react-query@11 @tanstack/react-query@5Keep your @trpc/* packages on matching versions. The generated router type imports from @trpc/server, so your frontend needs that package even though the API server runs in Go.
Install Zod if you generate schemas:
npm install zod@4Requirements
Section titled “Requirements”- Go 1.26 or newer.
- tRPC v11 client packages.
- Zod 4 when using
--zodorWithZodOutput.
Add Your Application Dependencies
Section titled “Add Your Application Dependencies”Choose the authentication and persistence libraries that fit your app. trpcgo provides a net/http handler with optional CORS handling, so you can use http.ServeMux, a compatible Go router, or an adapter for your preferred framework.
For server-side validation with validate tags, install a validator and pass it to WithValidator. Quick Start shows the setup with go-playground/validator.