{"id":48088,"library":"grpc-utils","title":"grpc-utils","description":"A TypeScript utility library (v1.0.27) that reduces boilerplate for gRPC operations in Node.js. It provides a GrpcClient class that auto-generates promise-based methods from proto definitions, plus helpers like encodeMetadata/decodeMetadata and grpcLoader for loading proto files. Ships with TypeScript types. Suitable for projects using gRPC with Node.js, aiming to simplify client setup and metadata handling. Alternates like @grpc/proto-loader and grpc itself require more manual wiring; grpc-utils abstracts common patterns.","status":"active","version":"1.0.27","language":"javascript","source_language":"en","source_url":"https://github.com/isaiahwong/grpc-utils","tags":["javascript","typescript"],"install":[{"cmd":"npm install grpc-utils","lang":"bash","label":"npm"},{"cmd":"yarn add grpc-utils","lang":"bash","label":"yarn"},{"cmd":"pnpm add grpc-utils","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core gRPC implementation for Node.js","package":"@grpc/grpc-js","optional":false},{"reason":"Loads .proto files and generates type definitions","package":"@grpc/proto-loader","optional":false},{"reason":"Used internally by GRPC-utils for metadata encoding/decoding","package":"protobufjs","optional":true}],"imports":[{"note":"ESM-only; CommonJS is not supported. Requires TypeScript or ES modules.","wrong":"const GrpcClient = require('grpc-utils');","symbol":"GrpcClient","correct":"import { GrpcClient } from 'grpc-utils';"},{"note":"Named export for encoding metadata.","symbol":"encodeMetadata","correct":"import { encodeMetadata } from 'grpc-utils';"},{"note":"Utility object with loadProto methods.","symbol":"grpcLoader","correct":"import { grpcLoader } from 'grpc-utils';"}],"quickstart":{"code":"import { GrpcClient } from 'grpc-utils';\nimport * as protoLoader from '@grpc/proto-loader';\nimport * as grpc from '@grpc/grpc-js';\nconst packageDefinition = protoLoader.loadSync('path/to/service.proto');\nconst proto = grpc.loadPackageDefinition(packageDefinition);\nconst client = new GrpcClient(\n  proto.my_package.MyService,\n  'localhost:50051',\n  grpc.credentials.createInsecure()\n);\nasync function main() {\n  try {\n    const response = await client.myMethod({ requestField: 'value' });\n    console.log('Response:', response);\n  } catch (error) {\n    console.error('Error:', error);\n  }\n}\nmain();","lang":"typescript","description":"Initializes a GrpcClient from a proto definition and calls a generated method with async/await."},"warnings":[{"fix":"Check generated method names after upgrade and adjust invocations.","message":"Method names are auto-generated from proto RPC names; they may be renamed across versions.","severity":"breaking","affected_versions":"0.x to 1.x"},{"fix":"Replace `const grpc = require('grpc')` with `import * as grpc from '@grpc/grpc-js'`.","message":"Older usage relied on `grpc` package (grpc); now requires `@grpc/grpc-js`.","severity":"deprecated","affected_versions":"<1.0"},{"fix":"Ensure the first argument is a gRPC client constructor (e.g., from `proto.my_package.MyService`) not an instance.","message":"GrpcClient expects a constructed gRPC client constructor, not a class. Passing the wrong object type will throw at runtime.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'abstract':75 'aim':54 'altern':62 'auto':24 'auto-gener':23 'base':28 'boilerpl':11 'class':21 'client':57 'common':76 'definit':32 'encodemetadata/decodemetadata':36 'file':42 'generat':25 'grpc':2,13,51,66,73 'grpc-util':1,72 'grpc/proto-loader':64 'grpcclient':20 'grpcloader':38 'handl':61 'helper':34 'javascript':78 'librari':7 'like':35,63 'load':40 'manual':70 'metadata':60 'method':29 'node.js':16,53 'oper':14 'pattern':77 'plus':33 'project':49 'promis':27 'promise-bas':26 'proto':31,41 'provid':18 'reduc':10 'requir':68 'setup':58 'ship':43 'simplifi':56 'suitabl':47 'type':46 'typescript':5,45,79 'use':50 'util':3,6,74 'v1.0.27':8 'wire':71","created_at":"2026-06-07T16:54:51.811259+00:00","updated_at":"2026-06-07T16:54:51.811259+00:00","problems":[{"fix":"Install and import @grpc/grpc-js: `npm install @grpc/grpc-js` and add `import * as grpc from '@grpc/grpc-js'`.","cause":"Missing import for @grpc/grpc-js","error":"ReferenceError: grpc is not defined"},{"fix":"Check proto file path and ensure the method exists; generated method names are camelCase of proto RPC names.","cause":"RPC method name mismatch or proto not loaded correctly","error":"TypeError: client.myMethod is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/isaiahwong/grpc-utils#readme","github":"https://github.com/isaiahwong/grpc-utils","docs":null,"changelog":null,"pypi":null,"npm":"grpc-utils","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}