Mitch528 / react-native-grpc

gRPC for react-native

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react-native-grpc

gRPC for react-native

Installation

npm install @mitch528/react-native-grpc

Usage

import { GrpcClient, GrpcMetadata } from '@mitch528/react-native-grpc';

GrpcClient.setHost('example.com');

// Bring your own protobuf library
// This example uses https://github.com/timostamm/protobuf-ts

const request = ExampleRequest.create({
  message: 'Hello World!',
});

const data: Uint8Array = ExampleRequest.toBinary(request);
const headers: GrpcMetadata = {};

const { response } = await GrpcClient.unaryCall(
  '/example.grpc.service.Examples/SendExampleMessage',
  data,
  headers
);

const responseMessage = ExampleMessage.fromBinary(response);

See examples project for more advanced usage.

Limitations

This library currently only supports unary and server-side streaming type RPC calls. PRs are welcome.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

About

gRPC for react-native

License:MIT License


Languages

Language:Java 32.3%Language:TypeScript 29.8%Language:Swift 23.5%Language:Objective-C 7.7%Language:Ruby 4.0%Language:JavaScript 2.4%Language:Shell 0.3%Language:C 0.2%