Skip to content

Install

trpcgo ships as a Go runtime package and a Go tool command.

Terminal window
go get github.com/befabri/trpcgo@latest

Import the runtime and HTTP protocol handler separately:

import (
"github.com/befabri/trpcgo"
"github.com/befabri/trpcgo/trpc"
)

With Go 1.26+, add the generator as a tool in go.mod:

tool github.com/befabri/trpcgo/cmd/trpcgo

Then run it with go tool:

Terminal window
mkdir -p web/gen
go tool trpcgo generate -o web/gen/trpc.ts --zod web/gen/zod.ts ./...

The CLI creates output files directly, so parent directories must already exist.

Install the tRPC client packages used by your frontend framework. For a vanilla client:

Terminal window
npm install @trpc/client @trpc/server

For React Query:

Terminal window
npm install @trpc/client @trpc/server @trpc/react-query @tanstack/react-query

For the TanStack React Query helper API shown in Frontend Setup:

Terminal window
npm install @trpc/client @trpc/server @trpc/tanstack-react-query @tanstack/react-query

Install Zod if you generate schemas:

Terminal window
npm install zod
  • Go 1.26 or newer.
  • tRPC v11 client packages.
  • Zod 4 when using --zod or WithZodOutput.

trpcgo does not add CORS, authentication, persistence, or a web framework. The HTTP handler is plain net/http, so mount it behind Chi, Echo, Fiber adapters, standard middleware, or a raw http.ServeMux.