---
title: "Create a k6 extension | Grafana k6 documentation"
description: "Learn how to create a k6 extension."
---

# Create a k6 extension

If you find a gap in your testing process that no k6 extension can fix, consider building your own extension. Use the tutorials below to get started.

- [Create a JavaScript extension](/docs/k6/next/extensions/create/javascript-extensions/) to extend the JavaScript functionality of your script or add support for a new network protocol to test.
- [Create an Output extension](/docs/k6/next/extensions/create/output-extensions/) to process the metrics emitted by k6 or publish them to unsupported backend stores.
- [Create a Secret Source extension](/docs/k6/next/extensions/create/secret-source_extensions/) to provide secrets to your k6 script at runtime.
- [Create a Subcommand extension](/docs/k6/next/extensions/create/subcommand-extensions/) to add custom CLI commands under the `k6 x` namespace.

## Necessary knowledge

Anyone who can use the command line to edit files and install software should be able to follow along. But, if you want to create an extension for more than the purposes of demonstration, there’s some background knowledge you should have:

- You should be familiar with both Go(lang), JavaScript, and their tooling
- You should understand how the [*Go-to-JavaScript*](/docs/k6/next/extensions/explanations/go-js-bridge/) bridge works within k6

> Note
> 
> If you maintain a public xk6 repository and wish to have your extension listed in our [registry](/docs/k6/next/extensions/explore/), be sure to review the [requirements](/docs/k6/next/extensions/create/extensions-registry/#registry-requirements).

## Avoid unneeded work

These actions may save you the trouble of building a whole new extension when its not needed.

- Confirm that a similar extension doesn’t already exist for your use case. Take a look at the [Extensions listing](/docs/k6/next/extensions/explore/) and the [`xk6` topic on GitHub](https://github.com/topics/xk6).
- Prefer generic solutions. For example, if you can test a system with a generic protocol like *MQTT*, prefer [xk6-mqtt](https://github.com/pmalhaire/xk6-mqtt) over a new extension for some custom protocol.
- Lean toward writing pure JavaScript libraries over building an extension in Go. A JavaScript library will be better supported, more straightforward, and reusable than an extension.
