# ConnectRPC — Simple Browser-Compatible RPC over HTTP > ConnectRPC is a slim RPC framework that generates type-safe clients and servers from Protobuf definitions, speaking gRPC, gRPC-Web, and its own HTTP-friendly Connect protocol through a single codebase. ## Install Save as a script file and run: # ConnectRPC — Simple Browser-Compatible RPC over HTTP ## Quick Use ```bash go install connectrpc.com/connect/cmd/protoc-gen-connect-go@latest ``` ```protobuf // greet/v1/greet.proto service GreetService { rpc Greet(GreetRequest) returns (GreetResponse) {} } ``` ```bash buf generate ``` Generated server and client code works with `net/http` directly. ## Introduction ConnectRPC simplifies RPC by building on standard HTTP. It generates type-safe clients and handlers from Protobuf schemas, and each server simultaneously speaks three protocols—Connect (simple HTTP), gRPC, and gRPC-Web—so browsers, mobile apps, and backend services all hit the same endpoint. ## What ConnectRPC Does - Generates type-safe client and server code from Protobuf service definitions - Serves the Connect, gRPC, and gRPC-Web protocols on a single port and handler - Works with `net/http` in Go, requiring no special HTTP server or mux - Supports unary, server-streaming, client-streaming, and bidirectional streaming RPCs - Provides interceptors for authentication, logging, and observability middleware ## Architecture Overview ConnectRPC generates handler and client code via `protoc-gen-connect-go` (Go), `@connectrpc/connect` (TypeScript), or plugins for other languages. Handlers register as standard HTTP handlers, detecting the protocol from each request's Content-Type header. The Connect protocol uses simple HTTP POST with JSON or Protobuf bodies—curl-friendly without special tooling. gRPC and gRPC-Web requests on the same endpoint are handled transparently. ## Installation & Configuration - Install the Buf CLI and `protoc-gen-connect-go` for Go code generation - Use `@connectrpc/connect` and `@connectrpc/connect-web` for TypeScript clients - Register handlers on any `http.ServeMux` or router—no proprietary server needed - Configure TLS and HTTP/2 via standard Go `net/http` or your preferred reverse proxy - Add interceptors in the handler or client constructor for cross-cutting concerns ## Key Features - Three protocols (Connect, gRPC, gRPC-Web) from a single handler implementation - Browser-native: the Connect protocol works with `fetch()` without a proxy - curl-friendly: `curl -X POST --json` works against Connect endpoints - Standard HTTP middleware compatibility (no gRPC-specific interceptor chains) - Streaming support across all three protocols including bidirectional ## Comparison with Similar Tools - **gRPC-Go** — requires `grpc.NewServer()` and HTTP/2; ConnectRPC uses `net/http` and adds browser support - **Twirp** — Protobuf-based RPC by Twitch; unary only, no streaming or gRPC compatibility - **gRPC-Web** — requires an Envoy or grpc-web proxy for browsers; ConnectRPC serves browsers directly - **tRPC** — TypeScript-native RPC without Protobuf; ConnectRPC provides cross-language schemas - **REST/OpenAPI** — manual endpoint design; ConnectRPC auto-generates clients and servers from a schema ## FAQ **Q: Can I call ConnectRPC services from a browser?** A: Yes. The Connect protocol uses standard HTTP and works natively with `fetch()`. The TypeScript client library handles serialization. **Q: Do I need Envoy or a special proxy?** A: No. ConnectRPC handlers serve gRPC, gRPC-Web, and Connect directly on standard HTTP, eliminating the need for a translation proxy. **Q: Which languages does ConnectRPC support?** A: Go, TypeScript/JavaScript, Swift, and Kotlin have official client and server libraries. The Connect protocol is simple enough for any HTTP client. **Q: Is ConnectRPC compatible with existing gRPC services?** A: Yes. ConnectRPC clients can call standard gRPC servers, and ConnectRPC servers accept standard gRPC clients. ## Sources - https://github.com/connectrpc/connect-go - https://connectrpc.com/ --- Source: https://tokrepo.com/en/workflows/asset-2d7ac20c Author: Script Depot