# Installing an extension

ScandiPWA setup considers having the back-end (Magento 2 Module) and front-end (ScandiPWA Extensions) of your application completely separated. If you are looking for back-end part instructions, refer to the link below.

{% content-ref url="/pages/-MVF\_BE8VZhydDrNynuE" %}
[Working with Magento modules](/developing-with-scandi/working-with-magento/working-with-magento-modules.md)
{% endcontent-ref %}

## Install from a local source

{% hint style="info" %}
**Note**: The following instructions are valid for **ScandiPWA 4.x** For **5.x**, please go to <https://marketplace.scandipwa.com/extension-manual-installation-guide>
{% endhint %}

1. Download the archive containing the FE part of the extension from the marketplace.
2. Create a `packages/` directory inside of your theme's root.
3. Put the archive's contents inside of the `packages/<package name>` directory. Make sure that you have a `packages/<package name>/package.json` file present alongside all the other extension's contents, that means that you have unpacked the extension correctly. Note: `<package name>` can also include publisher, `@scandipwa/paypal` is a valid package name.
4. Add the following scripts to the `scripts` section of your theme's `package.json` file. This is necessary for your package to be symlinked into the `node_modules` directory of your theme after manipulations with dependencies

   ```javascript
   {
       "scripts": {
           "postinstall": "scandipwa-scripts link",
           "postupdate": "scandipwa-scripts link"
       }
   }
   ```
5. Add the extension to the dependencies of your theme, as follows:

   ```javascript
   {
       "dependencies": {
           "<package name>": "file:packages/<package name>"
       }
   }
   ```
6. Update the symlinks by running the following command

   ```bash
   # For yarn users
   yarn postinstall

   # For npm users
   npm run postinstall
   ```
7. [Enable the extension](/developing-with-scandi/extensions/installing-an-extension.md#enable-the-extension)

## Install with a package manager (beta)

Some of the FE ScandiPWA extensions are available for installation using `npm` and `yarn`.

The process is different from the regular module's installation, the ScandiPWA packages are stored in our own registry - `r.scandipwa.com`

The installation process is the following:

1. Get the [credentials](https://marketplace.scandipwa.com/scandipwa_npmregistry/index/auth/) (token) from the [marketplace](https://marketplace.scandipwa.com/)
2. Configure the token for your project

   2.1. Create an `.npmrc` file inside of your project's root directory, neighboring to the `package.json` file. The `.npmrc` file should be created even if you are using `yarn`.

   2.2. Put your token in there in the following format:

   ```bash
   TOKEN=put.token.here
   //r.scandipwa.com/:_authToken=$TOKEN
   ```
3. Add the desired package to your project's dependencies (and fetch it)

   ```bash
   # Write a full command
   yarn --registry https://r.scandipwa.com add <package>
   npm --registry https://r.scandipwa.com i <package>

   # Or create an alias
   alias yr='yarn --registry https://r.scandipwa.com'
   alias npr='npm --registry https://r.scandipwa.com'

   # and use it
   yr add <package>
   npr i <package>
   ```
4. When installing your project's dependencies, don't worry about any additional actions. The `yarn.lock` or `package-lock.json` will contain all the necessary data

   ```bash
   # For yarn users
   yarn

   # For npm users
   npm ci
   ```
5. [Enable the extension](/developing-with-scandi/extensions/installing-an-extension.md#enable-the-extension)

## Enable the extension

Turn on the extension in your theme's `package.json` file. You may turn it off by changing `true` to `false` in the corresponding `extensions` block's entry.

```javascript
    {
        "scandipwa": {
            "extensions": {
                "<package name>": true
            }
        }
    }
```

## Install by using `scandipwa-cli`

Currently, it is possible to install the extensions published to `npm` with the `scandipwa-cli` package, by using `scandipwa extension install` command.

It is planned to provide support for installing local extensions in the future.

More information about installing via `scandipwa-cli` from `npm` registry see [here](https://docs.scandipwa.com/developing-with-scandi/developer-tools/scandipwa-cli).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.scandipwa.com/developing-with-scandi/extensions/installing-an-extension.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
