.NET › gRPC Services

What is gRPC-Web, and why is it needed for calling gRPC services directly from a browser-based JavaScript client?

Intermediate

Answer

Browsers don't provide the low-level HTTP/2 trailer access and full control needed for native gRPC's wire protocol, so gRPC-Web is a protocol variant designed to work within browser constraints (using standard HTTP requests the browser's fetch/XHR APIs can handle), requiring either a proxy (like Envoy) to translate between gRPC-Web and native gRPC, or ASP.NET Core's built-in Grpc.AspNetCore.Web middleware to natively accept gRPC-Web requests without a separate proxy.
builder.Services.AddGrpc();
var app = builder.Build();

app.UseGrpcWeb();  // enables gRPC-Web support directly, no separate proxy needed
app.MapGrpcService<GreeterService>().EnableGrpcWeb();
Real-world example A Blazor WebAssembly frontend calls a gRPC backend service directly using gRPC-Web support built into ASP.NET Core, avoiding the need to deploy and maintain a separate Envoy proxy just to bridge the browser-to-gRPC gap.

Common follow-ups: What specific browser limitations prevent native gRPC from working directly?;How does gRPC-Web's performance compare to native gRPC given the translation overhead?