grpc-web is the JavaScript client runtime library that enables browser-based applications to communicate with gRPC services. It functions by connecting to gRPC services through a specialized gateway proxy, such as Envoy, which has built-in gRPC-Web support. The current stable version is 2.0.2, with recent releases addressing bug fixes and minor improvements, including TypeScript compatibility updates. The project maintains a steady release cadence for bug fixes and incremental features. Key differentiators include its focus on browser environments, robust TypeScript support for generated client stubs, and the reliance on `protoc` and `protoc-gen-grpc-web` for generating client code and message definitions from `.proto` files, providing a full-stack gRPC experience for web clients.
npm install grpc-webVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to instantiate a gRPC-Web client, create a request, send it to a gRPC service through a proxy, and handle the response and potential errors using TypeScript.
Upgrade `grpc-web` to version 2.0.2 or newer to ensure compatibility with TypeScript 5.9+ through the use of regular enums in generated code. Regenerate your client stubs with the latest `protoc-gen-grpc-web`.
Ensure you have a gRPC-Web compatible proxy configured and running between your browser client and your gRPC backend. Refer to the gRPC-Web documentation for proxy setup instructions, typically using Envoy.
Download and install `protoc` from the official Protocol Buffers releases and `protoc-gen-grpc-web` from the gRPC-Web GitHub releases. Ensure both executables are in your system's PATH and have appropriate permissions.
Consistently use either `import_style=commonjs+dts` or `import_style=typescript` for `protoc-gen-grpc-web`. For modern TypeScript projects, `import_style=typescript` is often preferred. Ensure your `tsconfig.json` compiler options are compatible with the chosen import style.
Download `protoc-gen-grpc-web` from the GitHub releases page, place it in a directory included in your system's PATH, and ensure it has execute permissions (e.g., `chmod +x protoc-gen-grpc-web`).
Ensure `import * as grpcWeb from 'grpc-web';` is present and that your bundling tool (webpack, Parcel, Rollup) correctly includes the `grpc-web` library in your final output. Verify your `protoc-gen-grpc-web` output options match your project's module system (CommonJS/ESM).
Configure your gRPC-Web proxy (e.g., Envoy's CORS filter) to include the `Access-Control-Allow-Origin` header with the appropriate value (e.g., your frontend's URL or `*` for development) and allow necessary HTTP methods (POST, OPTIONS) and headers.
No dependency data recorded yet.