protobuf.js icon indicating copy to clipboard operation
protobuf.js copied to clipboard

How to use protobuf.js in a browser with gRPC?

Open ben-xD opened this issue 3 years ago • 1 comments

In the README, we have a section with using gRPC

  • the example uses a deprecated package grpc which 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

ben-xD avatar Apr 07 '22 09:04 ben-xD

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

kskalski avatar May 26 '22 08:05 kskalski