Skip to content

Getting Started

What is protoc-gen-nats-micro?

A Protocol Buffers compiler plugin that generates type-safe NATS microservice code using the official nats.io/micro framework.

Write standard .proto files, run buf generate, and get production-ready NATS microservices with:

  • Automatic service discovery and load balancing
  • Type-safe request/response handling
  • Configurable timeouts, interceptors, and headers
  • Streaming RPC (server, client, bidirectional)
  • KV Store and Object Store auto-persistence

Prerequisites

Installation

bash
go install github.com/toyz/protoc-gen-nats-micro/cmd/protoc-gen-nats-micro@latest

Proto Dependencies

Add the natsmicro proto options to your buf.yaml:

yaml
deps:
  - buf.build/toyz/natsmicro

This lets you use import "natsmicro/options.proto" in your proto files without copying anything locally.

Why not gRPC / nRPC?

protoc-gen-nats-microgRPCnRPC
Service discoveryBuilt-in via NATSRequires service meshManual
Load balancingNATS queue groupsExternal LBManual
Streaming✅ Server/Client/Bidi✅ All patterns❌ None
KV/Object auto-persist
Multi-languageGo, TS, PythonManyGo only
MaintenanceActiveActiveAbandoned
FrameworkOfficial nats.io/microgRPCCustom

Next Steps

Released under the MIT License.