Publishing Plugins
Learn how to package, document, and publish your Genkit plugins to npm so others can use them.Prerequisites
- Node.js and npm installed
- npm account (sign up here)
- TypeScript knowledge
- Completed plugin implementation
Package Structure
Recommended Directory Structure
Package Configuration
package.json
name- Usegenkitx-*prefix for community pluginskeywords- Includegenkit-pluginfor discoverabilitypeerDependencies- Requiregenkitas peer dependencyfiles- Only include necessary files (lib, README, LICENSE)exports- Support both CommonJS and ESM
tsconfig.json
.npmignore
Naming Conventions
Package Names
Official plugins (by Firebase/Google):@genkit-ai/plugin-name- e.g.,@genkit-ai/anthropic
genkitx-plugin-name- e.g.,genkitx-ollama,genkitx-pinecone
- Names starting with
genkit-(reserved for official packages) - Generic names like
genkit-ai-plugin
Keywords
Include relevant keywords for npm search:Documentation
README.md Template
API Documentation
Document all exported functions and types:Testing
Unit Tests
Publishing to npm
First-time Setup
- Create npm account:
- Verify login:
Publishing Steps
- Build the package:
- Test locally:
- Run tests:
- Update version:
- Publish:
Scoped Packages
For organization packages:Best Practices
1. Semantic Versioning
Follow semver:- Major (1.0.0 -> 2.0.0) - Breaking changes
- Minor (1.0.0 -> 1.1.0) - New features, backward compatible
- Patch (1.0.0 -> 1.0.1) - Bug fixes
2. Changelog
Maintain a CHANGELOG.md:3. License
Use Apache-2.0 to match Genkit:4. Types
Always include TypeScript declarations:5. Peer Dependencies
UsepeerDependencies for Genkit:
6. Security
- Don’t include API keys in code or tests
- Add
.envto.gitignore - Use environment variables for secrets
- Document security best practices
7. Examples
Provide working examples:Maintenance
Responding to Issues
- Triage issues promptly
- Label issues appropriately
- Provide clear reproduction steps
- Fix critical bugs quickly
Keeping Up-to-date
- Monitor Genkit releases
- Update peer dependency versions
- Test against new Genkit versions
- Update documentation
Deprecation
If deprecating features:Promotion
Share Your Plugin
- Genkit Discord - Announce in #plugins channel
- GitHub - Add
genkit-plugintopic to repository - Twitter/X - Share with #Genkit hashtag
- Blog post - Write about your plugin
- Documentation - Submit PR to genkit-ai/docsite
Badge for README
Resources
- npm Documentation
- Semantic Versioning
- Genkit Plugin Examples
- Creating Plugins Guide
- Plugin API Reference
Checklist
Before publishing:- Tests pass
- Documentation complete
- README with examples
- LICENSE file included
- Keywords in package.json
- TypeScript declarations
- Semantic version number
- Changelog updated
- No API keys in code
- Peer dependencies correct
-
npm packand test locally