gRPC for react-native
npm install @krishnafkh/react-native-grpcimport{GrpcClient,GrpcMetadata}from'@krishnafkh/react-native-grpc';GrpcClient.setHost('example.com');// Bring your own protobuf library// This example uses https://github.com/timostamm/protobuf-tsconstrequest=ExampleRequest.create({message: 'Hello World!',});constdata: Uint8Array=ExampleRequest.toBinary(request);constheaders: GrpcMetadata={};const{ response }=awaitGrpcClient.unaryCall('/example.grpc.service.Examples/SendExampleMessage',data,headers);constresponseMessage=ExampleMessage.fromBinary(response);See examples project for more advanced usage.
This library currently only supports unary and server-side streaming type RPC calls. PRs are welcome.
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT