Generate browser client (js + d.ts) files from proto files using protoc and grpc-web.
The server must also implement grpc-web for this to work.
npm install --dave-dev grpc-web-ts-compiler
Notes regarding included google-protobuf and @improbable-eng/grpc-web libs:
-
if you're not using a bundler like webpack, depending on how your frontend is built and consumed, you might get missing function errors; if this happens, ensure these are available at runtime.
-
if you're using a bundler that creates a
licenses.txt
file during build but libs are not included, you need to install them separately as production dependencies, to be corectly picked up.
npx proto "path/to/proto/dir" "path/to/generated/js_ts/dir"
Note only the top level proto files are processed by protoc binary, so ensure no subdirs are used