Remote plugins – Overview
Buf's remote plugins remove a key obstacle to generating code from Protobuf files—protoc
plugins are developed across many languages, and manual installation is inconsistent as a result.
Managing and maintaining a stable environment on a single machine is hard enough, and the problem is compounded as you scale out code generation across many developers.
Instead of maintaining plugins locally, you can reference protoc
plugins hosted in the Buf Schema Registry (BSR) in your buf.gen.yaml
files.
Buf verifies and maintains these copies of the plugins commonly used across the Protobuf ecosystem.
Finding remote plugins
To discover all publicly available plugins, go to buf.build/plugins:
-
Choose a collection or language:
Note
Plugins without an associated language or collection appear in the Other category at the bottom of the filter panel.
-
Click through to the group you want, and all available plugins display:
-
Choose the plugin you want to use, and it provides the reference to add to
buf.gen.yaml
and installation instructions for any dependencies:
Use the dropdown to change the version if needed. To use the latest version, remove the version number from the reference.
Using remote plugins
Using a plugin is as simple as referencing it in your buf.gen.yaml
config file.
Copy the YAML reference provided by the BSR and add it into the plugins
key of your buf.gen.yaml
file—for example:
version: v2
plugins:
# Use protoc-gen-go at v1.35.2
- remote: buf.build/protocolbuffers/go:v1.35.2
out: gen/go
opt: paths=source_relative
# Use the latest version of protoc-gen-go-grpc
- remote: buf.build/grpc/go
out: gen/go
opt: paths=source_relative
Then invoke buf generate
and you're done—no maintaining these plugins, no worrying about how to download or install them.
You've generated your stubs and can get back to solving real problems.
See the buf.gen.yaml
reference for more information about the other keys under plugin
.
Note
If you don't specify a plugin version, the latest version is used to generate. To avoid unexpected updates and possible breaking changes, pin to a specific version.
Request a public plugin
If you'd like a Protobuf plugin to be added to the Buf Schema Registry, open an issue.
Related docs
- Try out code generation with the
buf generate
tutorial - Browse the
buf generate
reference and thebuf.gen.yaml
reference - Find out how to create custom plugins for your organization