Skip to content

Comparison: connectrpc-axum vs connectrpc

Overview

connectrpc is a Rust implementation of the Connect protocol that provides both client and server components. It includes a Reqwest-based client and an Axum server implementation, with code generation for both. The project is in early development with streaming support being actively developed.

Feature Comparison

Featureconnectrpc-axumconnectrpc
Unary RPC (POST)
Unary RPC (GET)
Server streaming
Client streaming
Bidirectional streamingPlanned
JSON encoding
Protobuf encoding
Compression (gzip)
Timeouts
Error details
Message size limits
Tonic/gRPC interop
gRPC-Web
Generated client✅ (Reqwest)

API Comparison

connectrpc-axum:

rust
async fn say_hello(
    ConnectRequest(req): ConnectRequest<HelloRequest>,
) -> Result<ConnectResponse<HelloResponse>, ConnectError> {
    Ok(ConnectResponse::new(HelloResponse {
        message: format!("Hello, {}!", req.name.unwrap_or_default()),
    }))
}

HelloWorldServiceBuilder::new()
    .say_hello(say_hello)
    .build_connect()

connectrpc:

rust
async fn say_hello(
    state: State,
    req: UnaryRequest<HelloRequest>,
) -> Result<UnaryResponse<HelloResponse>> {
    Ok(UnaryResponse::new(HelloResponse {
        message: format!("Hello, {}!", req.into_message().name.unwrap_or_default()),
    }))
}

HelloWorldServiceAxumServer {
    state: my_state,
    say_hello,
}.into_router()

Key Technical Differences

  • Architecture: connectrpc-axum uses middleware (ConnectLayer) and Axum extractors for protocol handling, while connectrpc parses requests inline within handler trait implementations.

  • State handling: connectrpc-axum leverages Axum's native state management via State<T> extractor. connectrpc requires state to be passed explicitly as a field on the generated server struct.

  • Client generation: connectrpc generates Reqwest-based clients (Proto and JSON variants) at build time. connectrpc-axum is server-only and relies on existing Connect clients.

  • gRPC support: connectrpc-axum provides ContentTypeSwitch for routing between Connect and gRPC (Tonic) services. connectrpc is Connect-only with no gRPC interop.

  • Code output: connectrpc writes generated code to user-specified files (e.g., src/lib.rs). connectrpc-axum generates to OUT_DIR and uses include! macros.

Summary

connectrpc-axum strengthsconnectrpc strengths
Full streaming support (including bidi)Generated Reqwest client
Compression supportFlexible output file placement
Tonic/gRPC interopSimpler standalone library
Message size limitsCombined client+server in one crate
Idiomatic Axum extractors-

Released under the MIT License.