> For the complete documentation index, see [llms.txt](https://docs.scandipwa.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.scandipwa.com/developing-with-scandi/extensions/creating-an-extension.md).

# Creating an extension

For NPM package to be considered an extension, it must have a `package.json` field `scandipwa.type` equal to `extension`. For example:

```javascript
{
    "scandipwa": {
        "type": "extension"
    }
    ...
}
```

The **extensions are power-less without a theme**. The application compiles from theme sources. Extensions are just isolated pieces, which make some features of your application work.

Any package containing the `@namespace` magic comments **must** have a `scandipwa` block declared in its package.json file. Otherwise, the `@namespace` magic comments will not be handled correctly during the build time, hence will not work.

## Registering an extension <a href="#registering-an-extension" id="registering-an-extension"></a>

**Both themes and extensions can register extensions**. In order to do it, the extension should be added to `scandipwa.extensions` object of `package.json` . The extension must be a valid NPM package, therefore you are required to add it into `dependencies` field of your `package.json`. Like so:

```javascript
{
    "dependencies": {
        "@scandipwa/m2-theme": "0.0.2",
        ...
    },
    "scandipwa": {
        "extensions": {
            "@scandipwa/m2-theme": true
        },
        ...
    }
    ...
}
```

This process could be automated using [ScandiPWA CLI](https://docs.create-scandipwa-app.com/building-your-app/using-scandipwa-cli). First, make sure you are in your theme's root folder. Now, to install an extension from the NPM registry, you can use the following command:

```bash
scandipwa extension install <PACKAGE>
```

In order to create a new extension, use the following command:

```bash
scandipwa extension create <PACKAGE>
```

This command will create a new extension in the `packages` folder and register it in your current theme. It will be symlinked from `packages` to proper folder under `node_modules`.

## Enabling an extension <a href="#enabling-an-extension" id="enabling-an-extension"></a>

Enabling and disabling an extension is achieved by setting the `true`or `false` as a value of the extension key in `scandipwa.extensions` . Your theme can control enabled extensions across the whole application. This allows disabling the previously enabled extension. The sequence of preference in this case is:

1. Your theme enabled extensions
2. Your theme's parent themes enabled extensions
3. Extension enabled extensions

{% hint style="warning" %}

### Watch out! <a href="#watch-out" id="watch-out"></a>

Disabling a previously enabled extension can lead to layout-shifts and issues inside of your parent theme. Also, there might be extensions plugging into the extension you intend to disable, this can lead to unexpected results.
{% endhint %}

## Extension features <a href="#extension-features" id="extension-features"></a>

Extensions are a very important part of the ScandiPWA tool-chain. The following features are available:

* ​[Application plugins](https://docs.create-scandipwa-app.com/extensions/application-plugins)​
* ​[Build configuration plugins](https://docs.create-scandipwa-app.com/extensions/build-configuration-plugins)​
* ​[Module preference](https://docs.create-scandipwa-app.com/extensions/virtual-modules)​
* ​[File provision](https://docs.create-scandipwa-app.com/extensions/file-provision)
* [Translation bundles](https://docs.create-scandipwa-app.com/building-your-app/internationalization#translation-sources)
