tonic icon indicating copy to clipboard operation
tonic copied to clipboard

gRPC-Web wasm browser client implementation in tonic-web

Open titanous opened this issue 3 years ago • 5 comments

Feature Request

Crates

tonic-web

Motivation

Now that gRPC-Web support has been implemented and merged by @alce (#455), I think it's worth considering adding support for a gRPC-Web client implementation that works in browsers. This will allow users that are writing frontend apps in Rust to use gRPC natively via tonic without leaving the Rust ecosystem.

Proposal

I propose adding a new Client type to tonic-web that implements GrpcService using the browser Fetch API via js-sys/wasm-bindgen. I have prototyped this implementation at https://github.com/titanous/grpc-web-client and am happy to work on a PR to merge in the implementation.

This would be behind a feature flag that is not enabled by default so that it can be used in projects that use wasm-bindgen to target browsers.

Alternatives

The alternative is to keep this implementation as a separate third-party crate, but I think that it would be better for the ecosystem to have an easy to find implementation available in tonic.

titanous avatar May 13 '21 17:05 titanous

@titanous Is your implementation meant to replace https://github.com/grpc/grpc-web and https://github.com/improbable-eng/grpc-web?

rubik avatar May 14 '21 07:05 rubik

@titanous Is your implementation meant to replace https://github.com/grpc/grpc-web and https://github.com/improbable-eng/grpc-web?

Only for Rust use, I don’t plan to export JS bindings.

titanous avatar May 14 '21 10:05 titanous

Is it suitable to use the grpc-web-client prototype crate as an actual grpc web client today? I notice it points against branches of tonic that no longer exist.

ProjectMoon avatar Jun 03 '21 15:06 ProjectMoon

It should work if you point it at the lastest tonic master. I am planning to send a PR that will integrate it into this repository soon.

titanous avatar Jun 03 '21 15:06 titanous

Any way to get this effort going again? Seeing this merged into tonic would be awesome.

theduke avatar Apr 15 '22 20:04 theduke

I too would like to see this implemented. I'm working on a full-stack rust app and using gRPC would be fantastic.

mattoni avatar Dec 03 '22 16:12 mattoni

What's new?

Miuler avatar Jun 17 '23 00:06 Miuler

I have only seen this alternative: https://github.com/devashishdxt/tonic-web-wasm-client :(

Miuler avatar Jun 17 '23 00:06 Miuler