{"id":48082,"library":"grpc-ts-protoc-gen","title":"ts-grpc-protoc-gen","description":"Protoc plugin for generating TypeScript declarations (.d.ts) for gRPC service definitions. Version 0.1.1, no recent releases. It depends on ts-protoc-gen and generates CommonJS-compatible type definitions matching grpc-web or grpc JavaScript output. Differentiates from alternatives by focusing purely on type definitions for gRPC services, not message classes.","status":"maintenance","version":"0.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/koesie10/ts-grpc-protoc-gen","tags":["javascript","protobuf","protoc","typescript","ts","grpc","service","proto3"],"install":[{"cmd":"npm install grpc-ts-protoc-gen","lang":"bash","label":"npm"},{"cmd":"yarn add grpc-ts-protoc-gen","lang":"bash","label":"yarn"},{"cmd":"pnpm add grpc-ts-protoc-gen","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for generating TypeScript definitions for protobuf messages; this plugin only handles gRPC service stubs","package":"ts-protoc-gen","optional":false},{"reason":"Runtime dependency for gRPC client/server implementations used in generated code","package":"grpc","optional":true}],"imports":[{"note":"Service client classes are generated in separate *_grpc_pb files, not in message files","wrong":"import { UserServiceClient } from './generated/users_pb'","symbol":"UserServiceClient","correct":"import { UserServiceClient } from './generated/users_grpc_pb'"},{"note":"Message types are in *_pb files, service types in *_grpc_pb files","wrong":"import { GetUserRequest } from './generated/users_grpc_pb'","symbol":"GetUserRequest","correct":"import { GetUserRequest } from './generated/users_pb'"},{"note":"Must specify correct plugin name and path for grpc-ts; also requires ts-protoc-gen plugin for message types","wrong":"protoc --grpc-ts_out=. --plugin=protoc-gen-ts=./path","symbol":"protoc-gen-grpc-ts","correct":"protoc --plugin=protoc-gen-grpc-ts=./node_modules/.bin/protoc-gen-grpc-ts"}],"quickstart":{"code":"npm install --save-dev grpc-ts-protoc-gen ts-protoc-gen google-protobuf grpc-web\n# Generate code\nprotoc \\\n  --plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts \\\n  --plugin=protoc-gen-grpc-ts=./node_modules/.bin/protoc-gen-grpc-ts \\\n  --js_out=import_style=commonjs,binary:./generated \\\n  --ts_out=./generated \\\n  --grpc-web_out=import_style=typescript,mode=grpcweb:./generated \\\n  --grpc-ts_out=./generated \\\n  path/to/service.proto\n\n// Use generated code:\nimport { UserServiceClient } from './generated/users_grpc_pb';\nimport { GetUserRequest } from './generated/users_pb';\nconst client = new UserServiceClient('http://localhost:8080', null, null);\nconst req = new GetUserRequest();\nreq.setUsername('johndoe');\nclient.getUser(req, {}, (err, user) => { console.log(user); });","lang":"typescript","description":"Installs the plugin and protoc, generates gRPC TypeScript definitions, and demonstrates using a generated client."},"warnings":[{"fix":"Install ts-protoc-gen and add --ts_out flag to protoc invocation","message":"Requires ts-protoc-gen to be run separately; missing it will cause missing type definitions for messages","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Switch to @grpc/grpc-js and use grpc-web mode if browser, or consider grpc-tools","message":"Package uses deprecated grpc module; newer projects should use @grpc/grpc-js","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Use webpack or rollup with appropriate plugins to handle protobuf runtime resolution","message":"Generated .d.ts files assume Node.js CommonJS; may require additional setup for bundlers","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Set PROTOC_GEN_GRPC_TS_PATH=./node_modules/.bin/protoc-gen-grpc-ts","message":"Plugin binary name is 'protoc-gen-grpc-ts', but some projects mistakenly use 'grpc-ts-protoc-gen'","severity":"breaking","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'0.1.1':18 'altern':46 'class':58 'commonj':32 'commonjs-compat':31 'compat':33 'd.ts':12 'declar':11 'definit':16,35,52 'depend':23 'differenti':44 'focus':48 'gen':5,28 'generat':9,30 'grpc':3,14,38,41,54,64 'grpc-web':37 'javascript':42,59 'match':36 'messag':57 'output':43 'plugin':7 'proto3':66 'protobuf':60 'protoc':4,6,27,61 'pure':49 'recent':20 'releas':21 'servic':15,55,65 'ts':2,26,63 'ts-grpc-protoc-gen':1 'ts-protoc-gen':25 'type':34,51 'typescript':10,62 'version':17 'web':39","created_at":"2026-06-07T16:54:50.010759+00:00","updated_at":"2026-06-07T16:54:50.010759+00:00","problems":[{"fix":"Install the package and use the correct path: --plugin=protoc-gen-grpc-ts=./node_modules/.bin/protoc-gen-grpc-ts","cause":"The plugin path is incorrect or not executable; protoc cannot find the plugin binary","error":"protoc-gen-grpc-ts: program not found or is not executable"},{"fix":"Add --grpc-ts_out=<out_dir> to your protoc command","cause":"The generated types are missing because the --grpc-ts_out flag was not used during protoc invocation","error":"Cannot find module './generated/users_grpc_pb'"},{"fix":"Ensure google-protobuf is installed and generated .js files are included in your build/load path","cause":"Protobuf JavaScript runtime not imported or generated .js files not included in bundle","error":"TypeError: users_pb is undefined"},{"fix":"Run protoc with --ts_out flag alongside --grpc-ts_out using ts-protoc-gen plugin","cause":"TypeScript definitions are missing setter methods if ts-protoc-gen has not been run","error":"Property 'setUsername' does not exist on type 'GetUserRequest'"}],"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/koesie10/ts-grpc-protoc-gen#readme","github":"https://github.com/koesie10/ts-grpc-protoc-gen","docs":null,"changelog":null,"pypi":null,"npm":"grpc-ts-protoc-gen","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing","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}}