Connect RPC Documentation

website·Indexed Apr 13, 2026

https://connectrpc.com/docs/

Connect is a family of libraries for building browser and gRPC-compatible HTTP APIs using Protocol Buffer schemas. It supports code generation for Go, TypeScript, JavaScript, Swift, Kotlin, and Python. The documentation covers production-grade simplicity, seamless multi-protocol integration, and features including interceptors, observability, and error handling across Connect, gRPC, and gRPC-Web protocols.

Tokens
6.9K
Snippets
13
Records
62
Agent score
50%

What's inside Connect RPC

  1. Connect-ES v2 migration overview

    Version 2 of Connect-ES upgrades to Protobuf-ES version 2, removing the need for a dedicated code generator plugin. Messages are now plain TypeScript types, improving ecosystem compatibility—for example, messages can pass from Next.js server-side to client-side components without data loss. New framework support includes Next.js 15, Fastify 5, and Express 5. The upgrade brings support for Protobuf Editions and new APIs for messages with custom options. For detailed migration steps, refer to the migration guide at github.com/connectrpc/connect-es/blob/main/MIGRATING.md.
  2. Connect-Swift overview and capabilities

    Connect-Swift is a lightweight Swift library (<200KB) that generates type-safe, idiomatic Swift APIs from Protocol Buffers. It supports Connect, gRPC, and gRPC-Web protocols, eliminating the need for hand-written REST/JSON endpoints. The library provides generated mocks for testing and uses modern Swift features. It works with any backend implementing these protocols.
  3. Integrate generated code into Xcode project

    Drag the Generated/ directory into Xcode alongside your source files. When prompted, ensure your app target is selected under 'Add to targets:'. This compiles the generated .connect.swift and .pb.swift files into your application. Build the project to verify integration.
  4. HTTP/1.1 servers for Connect-Python services

    Connect only requires HTTP/2 for bidirectional streaming RPCs. Most services can use HTTP/1.1 servers without issue. Recommended servers with proven track records: gunicorn (WSGI applications) and uvicorn (ASGI applications). These are safe defaults if unsure which server to use.
  5. Create main activity layout with RecyclerView

    Create app/src/main/res/layout/activity_main.xml using ConstraintLayout. Include: a title TextView at top, a RecyclerView (id recycler_view) with LinearLayoutManager for chat messages, an EditText (id edit_text_view) for input, and a send Button (id send_button). The RecyclerView fills remaining space between title and input.
  6. Prerequisites for Connect-Swift

    Install the Buf CLI and ensure it is available in your $PATH. Buf is used for linting Protobuf files and generating Swift code from service definitions.
  7. Create chat list item layout (item.xml)

    Create app/src/main/res/layout/item.xml for a single chat entry. The layout uses a vertical LinearLayout containing a sender name TextView (hidden by default, shown for Eliza messages) and a message TextView. The sender name uses color #161EDE and the message uses black text.
  8. Testing Connect clients with in-memory transport

    Use createRouterTransport from @connectrpc/connect to test clients against an in-memory server. This bypasses network requests and tests routes in isolation. The returned Transport can create clients for calling procedures and asserting results. Benefits include easy setup, serialized messages, and support for headers, trailers, errors, and other Connect features. Drawback: behavior differs from real deployment since requests don't traverse the network.
  9. Connect-ES v2 system requirements

    Node.js 18.14.1 or higher required. TypeScript 4.9.6 or higher required. Older versions of Node.js and TypeScript are no longer supported.
  10. Migrate from grpc-python to connectrpc

    Migration steps: (1) Generate code with protoc-gen-connectrpc alongside existing grpc-python imports. (2) Migrate service implementations to Connect's generated stubs, extending protocol classes for type checking; replace abort calls with raise ConnectError. (3) Replace gRPC server startup with module-level app variable (WSGI/ASGI application). (4) Update deployment scripts to run with pyvoy. (5) Migrate clients: replace ManagedChannel with pyqwest transport, change metadata to headers, catch ConnectError. (6) Stop generating gRPC code once all services are deployed. Existing gRPC clients and Protobuf schemas work without modification.
  11. Set Cache-Control headers for caching

    Using GET requests does not automatically enable caching. Handlers must explicitly set Cache-Control response headers. Use max-age to specify cache duration in seconds, or private to restrict caching to the user agent only (excluding CDNs and proxies). Set headers via ctx.response_headers()["cache-control"].

    ctx.response_headers()["cache-control"] = "max-age=604800" return SayResponse()

  12. HTTP/2 and TLS requirements for gRPC clients

    Connect examples use HTTP 1.1 without TLS by default. However, gRPC clients require HTTP/2. To support both gRPC and browser clients, you need HTTP/2 with TLS. TLS negotiates the HTTP protocol version; without it, you must explicitly tell clients which HTTP version to use (e.g., --http2-prior-knowledge flag). Since browsers refuse HTTP/2 over cleartext, use locally-trusted development certificates for local development. See the Getting Started guide for setup steps.