Registry / api-client / testreactrpc

testreactrpc

JSON →
library1.0.205jsnpmunverified

A library providing full-featured integration of gRPC-Web into React applications. Current stable version 1.0.205 with rapid updates (multiple releases daily). Key differentiators: seamless hooks and components for gRPC-Web streaming, unary calls, and automatic state management. Unlike raw gRPC-Web clients, this library offers React-specific abstractions like useGrpcQuery and useGrpcMutation, reducing boilerplate. Supports TypeScript out of the box. Release cadence is high-frequency with frequent minor patches.

npm install testreactrpc
INSTALL
IMPORT
SIG · TESTREACTRPC
T
testreactrpc
api-clientjavascriptv1.0.205
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

GrpcProvider
import { GrpcProvider } from 'testreactrpc'
import GrpcProvider from 'testreactrpc'
Named export, not default.
useGrpcQuery
import { useGrpcQuery } from 'testreactrpc'
const { useGrpcQuery } = require('testreactrpc')
ESM-only; no CommonJS support.
GrpcClient
import { GrpcClient } from 'testreactrpc'
import { GrpcClient } from 'testreactrpc/dist/GrpcClient'
Re-exported from index; avoid deep imports.

Shows setting up GrpcProvider with a gRPC-Web client and using useGrpcQuery hook to call an echo method.

import React from 'react'; import { GrpcProvider, useGrpcQuery } from 'testreactrpc'; import { EchoServiceClient } from './generated/echo_grpc_web_pb'; const client = new EchoServiceClient('http://localhost:8080', null, null); function App() { return ( <GrpcProvider client={client}> <EchoComponent /> </GrpcProvider> ); } function EchoComponent() { const { data, loading, error } = useGrpcQuery({ method: 'echo', request: { message: 'Hello' }, }); if (loading) return <div>Loading...</div>; if (error) return <div>Error: {error.message}</div>; return <div>Response: {data?.message}</div>; } export default App;
Debug
Known issues
breakingv1.0.0 changed the signature of GrpcProvider: 'client' prop is now required and 'options' prop removed.
fix
Pass client prop and use 'clientOptions' if needed.
affects: >=1.0.0 <1.0.0
deprecateduseGrpcSubscription is deprecated since v1.0.100; use useGrpcQuery with streaming option instead.
fix
Replace with useGrpcQuery and set 'streaming: true'.
affects: >=1.0.100
gotchaGrpcProvider requires a client instance; passing a client class instead of instance causes runtime error.
fix
Ensure you instantiate the client with new before passing.
affects: >=1.0.0
gotchaThe library does not support CommonJS require(); it is ESM-only. Attempting require yields 'ERR_REQUIRE_ESM'.
fix
Use import syntax or migrate to ESM.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: client.echo is not a function
Using useGrpcQuery with 'method' name that doesn't exist on client.
fix
Check the generated client methods; method name should match exactly (e.g., 'echo', 'echoMessage').
Error: Not inside a GrpcProvider
Using a hook like useGrpcQuery outside of <GrpcProvider> wrapper.
fix
Wrap your component tree with <GrpcProvider> at the root.
Module not found: Can't resolve 'testreactrpc'
Package not installed or missing in tsconfig paths.
fix
Run 'npm install testreactrpc' and ensure your bundler resolves modules correctly.
Upgrade
Version history
1.0.205latest on npm
Audit
Dependencies
grpc-webrequiredCore gRPC-Web client for making RPC calls.
reactrequiredPeer dependency for React hooks and components.
Agent activity
24 hits · last 30 days
node
22
OpenAI (training)
1
Resources
testreactrpc — npm install testreactrpc · libregistry