Skip to content

Suited GRPC stub generator powered by Webpack Loader and Typescript Language Service Plugin

Notifications You must be signed in to change notification settings

wickedev/hallow

Repository files navigation

Hallow gRPC

A Seamless gRPC web client library without code generation by plugin system

Usage

Example Protobuf

syntax = "proto3";

package greeting;

service Greeting {
    rpc Greeting (GreetingRequest) returns (GreetingResponse);
}

message GreetingRequest {
    string name = 1;
}

message GreetingResponse {
    string message = 1;
}

Promise API

import { Client } from '@hallow/grpc-web';
import { GreetingStub } from './greeting.proto';

const client = new Client({ baseURL: '/api' });
const greeter = new GreetingStub(client);

const res = await greeter.greeting({ message: 'Hello, Ryan!' });
console.log(`hello from server: ${res.message}`);

React Hook API (with Suspense)

import { Client } from '@hallow/grpc-web';
import { GreetingHookStub } from './greeting.proto';
import { ErrorBoundary } from 'react-error-boundary';

const client = new Client({ baseURL: '/api' });
const greeter = new GreetingHookStub(client);

function Greeter() {
  const res = greeter.useGreeting({ message: 'Hello, Ryan!' });
  return <div>{`hello from server: ${res.message}`}</div>;
}

function App() {
  return (
    <Suspense fallback={'loading'}>
      <ErrorBoundary fallback={'Something went wrong'}>
        <Greeter />
      </ErrorBoundary>
    </Suspense>
  );
}

Dependencies

  • google-protobuf
  • @improbable-eng/grpc-web

About

Suited GRPC stub generator powered by Webpack Loader and Typescript Language Service Plugin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •