Registry /
messaging / react-native-grpc-service
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.
default
✓ import RNGrpcService from 'react-native-grpc-service';
✗ const RNGrpcService = require('react-native-grpc-service');
ESM default import is recommended; CJS require may not trigger native module linking correctly.
TodoService with dot notation
✓ GrpcService.TodoService.Create({ name: 'test' }).then(...)
✗ new GrpcService().TodoService.Create(...)
GrpcService is a class instantiated with server address; service methods are accessed directly on the instance.
Configuration via JSON file
✓ Place react-native-grpc-service.json in project root with protoDirectory and protoFile.
✗ Pass config directly to constructor
Configuration is read from the JSON file at app startup, not passed programmatically.
Shows full setup: install, config file, class instantiation, and unary request call.
// 1. Install: npm install react-native-grpc-service
// 2. Create react-native-grpc-service.json at project root:
{
"protoDirectory": "../server/proto",
"protoFile": "app.proto"
}
// 3. Native linking (assuming react-native >= 0.60):
// iOS: pod install, then add RNGrpcService.xcodeproj to Libraries
// Android: Manual steps as per README
// 4. GrpcService.ts:
import RNGrpcService from 'react-native-grpc-service';
const grpcService = new RNGrpcService('localhost:8080');
export default grpcService;
// 5. App.tsx:
import React, { useEffect } from 'react';
import grpcService from './GrpcService';
function App() {
useEffect(() => {
grpcService.TodoService.Create({ name: 'test' }).then(response => {
console.log(response.data);
}).catch(error => console.error(error));
}, []);
return <View />;
}
Errors
Common errors & fixes
Error: Cannot find module 'react-native-grpc-service'
Package not installed correctly or node_modules missing.
fixRun 'npm install react-native-grpc-service' and ensure it's in dependencies.
RNGrpcService is not a constructor
Using default import incorrectly in CommonJS environment.
fixUse 'import RNGrpcService from 'react-native-grpc-service'' or 'const RNGrpcService = require('react-native-grpc-service').default'. Native module cannot be null
Native linking not completed correctly.
fixRe-run 'react-native link' or manually link libraries per README.
Audit
Dependencies
react-nativerequiredPeer dependency required for native module