@ehp/react-native-grpc
TypeScript icon, indicating that this package has built-in type declarations

0.1.10 • Public • Published

react-native-grpc

gRPC for react-native

Installation

npm install @ehp/react-native-grpc

Usage

import { GrpcClient, GrpcMetadata } from '@ehp/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

/@ehp/react-native-grpc/

    Package Sidebar

    Install

    npm i @ehp/react-native-grpc

    Weekly Downloads

    0

    Version

    0.1.10

    License

    MIT

    Unpacked Size

    226 kB

    Total Files

    69

    Last publish

    Collaborators

    • eugenehp