{"id":48724,"library":"nice-grpc","title":"nice-grpc","description":"nice-grpc is a Node.js gRPC library that provides a modern, promise-based API with full TypeScript support. Current stable version is 2.1.16, with a release cadence of approximately every 2-3 months. It supports async-iterable server streaming, abort signals for cancellation, and integrates seamlessly with @grpc/grpc-js. Compared to grpc-js, it offers a higher-level, more ergonomic interface with automatic promise wrapping, streaming with async iterables, and built-in TypeScript types. It is designed to be compatible with all standard gRPC features including unary, server streaming, client streaming, and bidirectional streaming.","status":"active","version":"2.1.16","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","grpc","promise","async-iterable","abort-controller","abort-signal","typescript"],"install":[{"cmd":"npm install nice-grpc","lang":"bash","label":"npm"},{"cmd":"yarn add nice-grpc","lang":"bash","label":"yarn"},{"cmd":"pnpm add nice-grpc","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Underlying gRPC core implementation","package":"@grpc/grpc-js","optional":false},{"reason":"Abort signal support in older Node.js versions","package":"abort-controller","optional":true}],"imports":[{"note":"ESM-only module; cannot use require() directly without destructuring. Since v2, only ESM is supported.","wrong":"const niceGrpc = require('nice-grpc');\nconst { createChannel } = niceGrpc","symbol":"createChannel","correct":"import { createChannel } from 'nice-grpc'"},{"note":"createServer is a named export, not default export. This is a common mistake.","wrong":"import createServer from 'nice-grpc'","symbol":"createServer","correct":"import { createServer } from 'nice-grpc'"},{"note":"TypeScript users often forget that ServerError is also exposed as a class; it's used to throw gRPC errors with status codes.","wrong":null,"symbol":"ServerError","correct":"import { ServerError } from 'nice-grpc'"}],"quickstart":{"code":"import { createChannel, createClient } from 'nice-grpc';\nimport { GreeterClient } from './generated/proto/example';\n\nconst channel = createChannel('localhost:8080');\n\nasync function main() {\n  const client = createClient(GreeterClient, channel);\n\n  const response = await client.sayHello({ name: 'World' });\n  console.log('Greeting:', response.message);\n\n  channel.close();\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Creates a gRPC channel and client, makes a unary RPC call with await, then closes the channel."},"warnings":[{"fix":"Migrate to ESM by setting 'type': 'module' in package.json or use .mjs extension. Alternatively, stick with v1.x (CJS).","message":"nice-grpc v2 is ESM-only. CommonJS require() is not supported.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Run 'npm install @grpc/grpc-js' as a dependency.","message":"The library depends on @grpc/grpc-js; you must install it as a peer dependency (if not already listed in package.json).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Replace deadline with AbortSignal: import { AbortController } from 'abort-controller' (if needed) and pass { signal: controller.signal }.","message":"In v2, the 'deadline' option is deprecated; use 'signal' with an AbortSignal instead.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Use for-await-of to consume the stream iterable properly.","message":"Server streaming uses async iterables. A common mistake is to use .toArray() on the stream, which may cause memory issues for large streams.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Remove callback argument; use await or .then().","message":"In v2.0, the client methods no longer accept a callback; they always return Promises.","severity":"breaking","affected_versions":"2.0.0"}],"env_vars":null,"search_vec":"'-3':37 '2':36 '2.1.16':28 'abort':46,110,113 'abort-control':109 'abort-sign':112 'api':19 'approxim':34 'async':42,75,107 'async-iter':41,106 'automat':70 'base':18 'bidirect':101 'built':79 'built-in':78 'cadenc':32 'cancel':49 'client':98 'compar':55 'compat':88 'control':111 'current':24 'design':85 'ergonom':67 'everi':35 'featur':93 'full':21 'grpc':3,6,10,58,92,104 'grpc-js':57 'grpc/grpc-js':54 'higher':64 'higher-level':63 'includ':94 'integr':51 'interfac':68 'iter':43,76,108 'javascript':103 'js':59 'level':65 'librari':11 'modern':15 'month':38 'nice':2,5 'nice-grpc':1,4 'node.js':9 'offer':61 'promis':17,71,105 'promise-bas':16 'provid':13 'releas':31 'seamless':52 'server':44,96 'signal':47,114 'stabl':25 'standard':91 'stream':45,73,97,99,102 'support':23,40 'type':82 'typescript':22,81,115 'unari':95 'version':26 'wrap':72","created_at":"2026-06-07T16:58:08.308799+00:00","updated_at":"2026-06-07T16:58:08.308799+00:00","problems":[{"fix":"npm install @grpc/grpc-js","cause":"@grpc/grpc-js is not installed as a dependency","error":"Error: Cannot find module '@grpc/grpc-js'"},{"fix":"import { createClient } from 'nice-grpc'","cause":"Using default import instead of named import","error":"TypeError: (0 , nice_grpc.createClient) is not a function"},{"fix":"Use import syntax or switch to v1.x","cause":"Using require() with nice-grpc v2 which is ESM-only","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module not supported"}],"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":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"nice-grpc","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"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}}