Running gRPC from Browser via gRPC-Web

Learn how to make gRPC calls from the browser using gRPC-Web.

gRPC-Web is a framework that allows us to make gRPC calls directly from the browser. However, it has limited capabilities compared to the standard gRPC calls made by non-browser clients. For example, browsers don't support all HTTP/2 features that the standard gRPC framework needs. Therefore HTTP/1.1 is used with gRPC-Web, but this cancels out some of the advantages of using gRPC.

Another limitation of gRPC-Web is that it doesn't support client-streaming calls. Therefore, both the standard client-streaming calls and the bi-directional streaming calls are off-limits.

Nevertheless, gRPC-Web is still useful. The calls made over it still use optimized binary payloads, which makes it more efficient than making standard HTTP calls. Therefore, the framework is still worth looking at.

Implementation of gRPC-Web

There are multiple ways of implementing gRPC-Web. We can do it via a JavaScript library. However, if we're using .NET, we can also use it inside Blazor. The Blazor WebAssembly implementation is what we'll cover in this lesson. Our original setup is available in the code widget below.

Get hands-on with 1200+ tech skills courses.