Extension types
k6 supports four types of extensions:JavaScript Extensions
Extend the JavaScript APIs available to your test scripts. Add support for new network protocols, improve performance, or add features.
Output Extensions
Send metrics to a custom file format or service. Add custom processing and dispatching methods.
Secret Source Extensions
Provide secrets to your tests from external sources.
Subcommand Extensions
Add custom CLI commands under the
k6 x namespace for setup, validation, and integration tools.Official vs community extensions
Official extensions
These extensions are owned and maintained by Grafana Labs, with support for a wide range of k6 versions. Official extensions include:- k6/x/mqtt - MQTT protocol support
- k6/x/redis - Redis database interaction
- k6/x/sql - SQL database testing
- k6 browser - Browser automation and end-to-end testing
- xk6-disruptor - Chaos testing and fault injection
Community extensions
Community extensions are developed by the k6 ecosystem, supporting specific versions. While not maintained by Grafana Labs, many provide valuable functionality for specialized testing needs.Many extensions maintained by members of the k6 ecosystem are available on GitHub. These extensions aren’t maintained nor audited by Grafana Labs.
Using extensions
There are two ways to use extensions in your k6 tests:Automatic extension resolution
Official and community extensions can be used without additional configuration. Simply import them in your test script:To use community extensions, set
K6_ENABLE_COMMUNITY_EXTENSIONS=true:Custom k6 binary
For custom extensions or output extensions, build a custom k6 binary using xk6:Getting started
Explore available extensions
Browse the Extensions catalog to find extensions for your use case.
Try an extension
Start with an official extension like xk6-disruptor for chaos testing or k6 browser for browser automation.
Build your own
Create custom extensions when you need specialized functionality. See Creating Extensions.
Why use extensions?
Extensions enable you to:- Test new protocols - Add support for MQTT, Redis, gRPC, and more
- Integrate with tools - Send metrics to your preferred monitoring systems
- Enhance performance - Use Go’s speed for computationally intensive operations
- Customize workflows - Add CLI commands for your specific testing process
- Manage secrets - Securely inject credentials from external vaults
- Extend capabilities - Add chaos testing, browser automation, and more
Next steps
Explore Extensions
Find extensions for your testing needs
Create Extensions
Build custom extensions in Go
Bundle Extensions
Build custom k6 binaries with xk6
xk6-disruptor
Inject faults for chaos testing