Registry / devops / grpc-common-client

grpc-common-client

JSON →
library1.0.9jsnpmunverified

A common gRPC client library for Node.js applications built on top of the official @grpc/grpc-js package. Version 1.0.9 provides a simplified interface for creating gRPC connections, managing channels, and handling client lifecycle. It abstracts away complexity of the underlying @grpc/grpc-js API, offering defaults for common scenarios. Suitable for microservices with internal gRPC communication, but may see limited updates due to low activity. Uses Promise-based patterns and supports TLS and insecure connections.

npm install grpc-common-client
INSTALL
IMPORT
SIG · GRPC-COMMON-CLIENT
G
grpc-common-client
devopsjavascriptv1.0.9
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.

GrpcClient
import { GrpcClient } from 'grpc-common-client'
const GrpcClient = require('grpc-common-client').default
Default export is available, but named export GrpcClient is preferred since v1.0.0
createClient
import { createClient } from 'grpc-common-client'
import createClient from 'grpc-common-client'
createClient is a named export, not default
GrpcClientOptions
import type { GrpcClientOptions } from 'grpc-common-client'
import { GrpcClientOptions } from 'grpc-common-client'
Type-only import recommended when using TypeScript; runtime import works but may bloat bundle

Two ways to create a gRPC client: using the GrpcClient class for fine-grained control, or the createClient factory for simpler setup with proto file loading.

import { GrpcClient, createClient } from 'grpc-common-client'; // Option 1: Using class const client = new GrpcClient({ target: 'localhost:50051', credentials: GrpcClient.credentials.createInsecure(), packageDefinition: protoLoader.loadSync('service.proto', { keepCase: true, longs: String, enums: String, defaults: true, oneofs: true }), serviceName: 'MyService' }); // Option 2: Using factory const client2 = createClient({ target: process.env.GRPC_HOST ?? 'localhost:50051', insecure: true, protoPath: './protos/service.proto', packageName: 'mypackage', serviceName: 'MyService' }); async function callService() { const response = await client.call('myMethod', { requestField: 'value' }); console.log(response); } callService().catch(console.error);
Debug
Known issues
gotchaProto file loading is not built-in; you must use @grpc/proto-loader separately
fix
Install @grpc/proto-loader and pass loaded packageDefinition to GrpcClient or use createClient with protoPath option which handles loading internally (requires @grpc/proto-loader to be installed)
affects: >=1.0.0
breakingIn v1.0.0, the constructor signature changed from positional arguments to single options object
fix
Upgrade: new GrpcClient({ target: '...', credentials: ..., packageDefinition: ..., serviceName: ... })
affects: >=1.0.0 <1.0.0
gotchaCredentials must be explicitly provided or use createClient's insecure option; no default
fix
Always specify credentials or use createClient with insecure: true
affects: >=1.0.0
deprecatedThe default export GrpcClient will be removed in v2.0.0; use named exports instead
fix
Replace default import with named import: import { GrpcClient } from 'grpc-common-client'
affects: >=1.0.5
Errors
Common errors & fixes
Error: Cannot find module 'grpc-common-client'
Package not installed or incorrect import path
fix
Run 'npm install grpc-common-client' and ensure import is from 'grpc-common-client' (no subpath)
TypeError: GrpcClient.credentials.createInsecure is not a function
Credentials not accessed correctly after v1.0.0
fix
Use GrpcClient.credentials.createInsecure() or import { credentials } from '@grpc/grpc-js'
Upgrade
Version history
1.0.9latest on npm
Audit
Dependencies
@grpc/grpc-jsrequiredCore gRPC implementation for Node.js
Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
grpc-common-client — npm install grpc-common-client · libregistry