{"library":"protoc-gen-grpc","title":"protoc-gen-grpc-ts","description":"Protocol Buffers compiler (protoc) plugin to generate TypeScript type definitions (d.ts) for gRPC service interfaces and message types from .proto files. Version 3.0.0 supports both the 'grpc' and '@grpc/grpc-js' runtime packages. This plugin is not a code generator for JavaScript (you still need protoc-gen-grpc for JS), it only produces type declaration files for TypeScript projects. Can be installed globally or per project. Note: the plugin is designed for Node.js (engine >=16) and requires protoc installed separately.","language":"javascript","status":"active","last_verified":"Fri May 01","install":{"commands":["npm install protoc-gen-grpc"],"cli":null},"imports":["import { ProductServiceService } from './path/to/generated/product_grpc_pb';","import * as product_pb from './path/to/generated/product_pb';","import * as grpc from '@grpc/grpc-js';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"// Install protoc-gen-grpc globally\nnpm install -g protoc-gen-grpc\n\n# Generate JavaScript and TypeScript definitions for a .proto file\n# Make sure protoc is installed (https://github.com/protocolbuffers/protobuf/releases)\n\nprotoc \\\n  --js_out=import_style=commonjs,binary:./generated \\\n  --grpc_out=grpc_js:./generated \\\n  --ts_out=grpc_js:./generated \\\n  --proto_path=./protos \\\n  ./protos/example.proto\n\n# Now you can use the generated types in your TypeScript server\nimport * as grpc from '@grpc/grpc-js';\nimport { ExampleServiceService } from './generated/example_grpc_pb';\n\nconst server = new grpc.Server();\nserver.addService(ExampleServiceService, { /* your implementation */ });\n","lang":"typescript","description":"Shows global installation, protoc invocation (with three output plugins), and then TypeScript server snippet using the generated service definition.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}