9.3k GitHub stars and counting — grpc/grpc-web is a JavaScript project TopGit is tracking across repositories on the platform. gRPC for Web Clients
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
A JavaScript implementation of gRPC for browser clients. For more information,
including a quick start, see the gRPC-web documentation.
gRPC-web clients connect to gRPC services via a special proxy; by default,
gRPC-web uses Envoy.
In the future, we expect gRPC-web to be supported in language-specific web
frameworks for languages such as Python, Java, and Node. For details, see the
roadmap.
Streaming Support
gRPC-web currently supports 2 RPC modes:
Unary RPCs (example)
Server-side Streaming RPCs (example) (NOTE: Only when grpcwebtext mode is used.)
Client-side and Bi-directional streaming is not currently supported (see streaming roadmap).
Quick Start
Eager to get started? Try the Hello World example. From this example, you'll
learn how to do the following:
Define your service using protocol buffers
Implement a simple gRPC Service using Node.js
Configure the Envoy proxy
Generate protobuf message classes and client service stub for the client
Compile all the JS dependencies into a static library that can be consumed
by the browser easily
Advanced Demo: Browser Echo App
You can also try to run a more advanced Echo app from the browser with a
streaming example.
You can then use Browserify, Webpack, Closure Compiler, etc. to resolve imports
at compile time.
Import Style
import_style=closure: The default generated code has
Closure goog.require()
import style.
import_style=commonjs: The
CommonJS style require() is
also supported.
import_style=commonjs+dts: In addition to above, a .d.ts
typings file will also be generated for the protobuf messages and service stub
import_style=typescript: The service stub will be generated
in TypeScript. See TypeScript Support below for information on how to
generate TypeScript files.
Note: The commonjs+dts and typescript styles are only supported by
--grpc-web_out=import_style=..., not by --js_out=import_style=....
Wire Format Mode
For more information about the gRPC-web wire format, see the
specification.
mode=grpcwebtext: The default generated code sends the payloads in the
grpc-web-text format.
Content-Type: application/grpc-web-text
Payloads are base64-encoded.
Both unary and server streaming calls are supported.
mode=grpcweb: A binary protobuf format is also supported.
Content-Type: application/grpc-web+proto
Payloads are in the binary protobuf format.
Only unary calls are supported.
How It Works
Let's take a look at how gRPC-web works with a simple example. You can find out
how to build, run and explore the example yourself in
Build and Run the Echo Example.
1. Define your service
The first step when creating any gRPC service is to define it. Like all gRPC
services, gRPC-web uses
protocol buffers to define
its RPC service methods and their message request and response types.
Next you need to have a gRPC server that implements the service interface and a
gateway proxy that allows the client to connect to the server. Our example
builds a simple Node gRPC backend server and the Envoy proxy.
For the Echo service: see the
service implementation.
For the Envoy proxy: see the
config YAML file.
3. Write your JS client
Once the server and gateway are up and running, you can start making gRPC calls
from the browser!
Create your client:
var echoService = new proto.mypackage.EchoServiceClient(
'http://localhost:8080');
Make a unary RPC call:
var request = new proto.mypackage.EchoRequest();
request.setMessage(msg);
var metadata = {'custom-header-1': 'value1'};
echoService.echo(request, metadata, function(err, response) {
if (err) {
console.log(err.code);
console.log(err.message);
} else {
console.log(response.getMessage());
}
});
Server-side streaming:
var stream = echoService.serverStreamingEcho(streamRequest, metadata);
stream.on('data', function(response) {
console.log(response.getMessage());
});
stream.on('status', function(status) {
console.log(status.code);
console.log(status.details);
console.log(status.metadata);
});
stream.on('end', function(end) {
// stream end signal
});
// to close the stream
stream.cancel();
For an in-depth tutorial, see this
page.
Setting a Deadline
You can set a deadline for your RPC by setting a deadline header. The value
should be a Unix timestamp, in milliseconds.
var deadline = new Date();
deadline.setSeconds(deadline.getSeconds() + 1);
client.sayHelloAfterDelay(request, {deadline: deadline.getTime().toString()},
(err, response) => {
// err will be populated if the RPC exceeds the deadline
...
});
TypeScript Support
The grpc-web runtime library is now fully written in TypeScript! This provides first-class type safety, zero runtime dependencies, and built-in type definitions out of the box.
You can simply import it into your TypeScript projects without needing external typings.
When using the protoc-gen-grpc-web protoc plugin, mentioned above, pass in
either:
Do not use import_style=typescript for --js_out, it will silently be
ignored. Instead you should use --js_out=import_style=commonjs, or
--js_out=import_style=commonjs,binary if you are using mode=grpcweb. The
--js_out plugin will generate JavaScript code (echo_pb.js), and the
-grpc-web_out plugin will generate a TypeScript definition file for it
(echo_pb.d.ts). This is a temporary hack until the --js_out supports
TypeScript itself.
For example, this is the command you should use to generate TypeScript code
using the binary wire format:
Yes — grpc/grpc-web ships under the Apache-2.0 license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/grpc/grpc-web.
What else is in the API space?
grpc/grpc-web is tracked by TopGit under the API category, alongside 3 GitHub-tagged topics. Trending and Topics pages list peer repositories of comparable stars and language.
What is grpc/grpc-web?
grpc/grpc-web (grpc/grpc-web) is a JavaScript project on GitHub. From the project's own README: gRPC for Web Clients
What license does grpc/grpc-web use?
grpc/grpc-web is released under the Apache-2.0 license. Always verify the LICENSE file directly on GitHub for the authoritative terms — license strings can be edited out of sync with a project's actual stance.
Where can I see grpc/grpc-web in action?
The project maintains a homepage at https://grpc.io. The README tab on this page also usually contains screenshots and a quickstart.
Where do I read more about grpc/grpc-web?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/grpc/grpc-web is the definitive source.
Why is grpc/grpc-web categorized under API?
TopGit places grpc/grpc-web in the API category based on its GitHub topics and description (tagged: "grpc", "javascript", "web"). Categories are assigned from real repository metadata, not editorial guesswork.
Read full README in the tab above.
Is grpc-web worth your time?
ChatGPT, Claude and Perplexity can all read this page. Ask one of them what it makes of grpc-web.