protobuf.js
protobuf.js copied to clipboard
How to use protobuf.js in a browser with gRPC?
In the README, we have a section with using gRPC
- the example uses a deprecated package
grpcwhich has been replaced with@grpc/grpc-js. Both packages appear to be for Node only, not browsers. - Because we use it in a browser, we probably need to use grpc-web. Not grpc-web NPM package, but the specification.
Is there a way to use protobuf.js on browsers whilst using grpc? Or does someone need to use grpc-web and avoid protobufjs completely?
This was also requested and upvoted by others in this comment: https://github.com/protobufjs/protobuf.js/issues/1035#issuecomment-385709878
Thanks for reading
For a out of the box working solution you should rather look at protobuf-ts with its https://github.com/timostamm/protobuf-ts/blob/master/MANUAL.md#grpc-web-transport