npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

use-grpc

v0.2.11

Published

Hooks for fetching asynchronous GRPC data in React!

Downloads

15

Readme

useGRPC hook for interact with grpc application

install size npm total downloads

Have you ever tried to bring grpc connection to the web?

then, you may need grpc-web for handle this type of requests.

for normal use of grpc-web, you wont have hard time, but when types comes important, you may have nightmare :D

using grpc-web is kinda ugly at first, you can see the document here.

but you can leave everythings to use-grpc for handling request and it will return everythings you need.

this hook will use grpc-web under the hood at all.

Usage

The use-grpc is available at npm:

$ npm i use-grpc
// or using yarn
$ yarn add use-grpc

(Depend on your proto files, you may need to install grpc-web and google-protobuf too)

Then you need to config your gateway and api methods:

import { createGateway } from 'use-grpc'

import * as HelloModel from './hello_pb'
import { HelloServiceClient } from './HelloServiceClientPb'

import * as GoodByeModel from './goodbye_pb'
import { GoodByeServiceClient } from './GoodByeServiceClientPb'

const baseUrl = "http://www.example.com"

const gateway = createGateway({
    HelloService: {
        client: createService(HelloServiceClient, baseUrl),
        model: HelloModel
    },
    GoodByeService: {
        client: createService(GoodByeServiceClient, baseUrl),
        model: GoodByeModel
    }
})

export { gateway }

createService will make Service client with specified url (we add option for include credentials in the future). createGateway will make Gateway (using gateway without this function may have issue with undefined this, so we bind this to the gateway)

After create gateway, create your api like this:

import { gateway } from './config.ts'

const api = {
    sayHello: {
        client: gateway.HelloService.client.sayHello,
        payload: () => new gateway.HelloService.model.HelloRequest()
    }
}

export { api }

Then you need to wrap your application with GrpcQueryProvider.

import { GrpcQueryProvider } from 'use-grpc'

export default function App() {
  return (
        <!-- Another Provider -->
            <GrpcQueryProvider>
                <RootComponent />
            </GrpcQueryProvider>
        <!-- Another Provider -->
    )
}

finally you can use useGRPC hook to fetch data:

import { useGRPC } from 'use-grpc';
import { api } from './api';

const ExampleApplication = () => {
  const { data, call, isLoading, error } = useGRPC(api.sayHello);

  return (
    <div>
      ...
    </div>
  );
};

Or if you want more example, take a look at here.

CONTRIBUTING

Feel free to ask for feature, Any Pull Request will be appreciated.

Currently we are on pre-release version, so maybe you can't use this on the production :D