<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [XInstaller](./x-components.xinstaller.md)

## XInstaller class

The purpose of this class is to offer a quick way to initialize the XComponents in a setup project. It allows to receive all the options in [InstallXOptions](./x-components.installxoptions.md) which is an extension of [XPluginOptions](./x-components.xpluginoptions.md) with all the options for the plugin and some options more.

This class does multiple things: 1. Install the [XPlugin](./x-components.xplugin.md) with the [XPluginOptions](./x-components.xpluginoptions.md)<!-- -->. 2. Creates the public [XAPI](./x-components.xapi.md) and add it to global window. 3. Creates the Vue Application for the customer project.

The steps 2 &amp; 3 are optional and depends on the options passed in [InstallXOptions](./x-components.installxoptions.md)<!-- -->.

**Signature:**

```typescript
export declare class XInstaller 
```

## Example

The way to use this class is the next: 1. Create the installer passing in the [InstallXOptions](./x-components.installxoptions.md)<!-- -->. This only save the options:

```
       const installer = new XInstaller(installXOptions)
```
2. Initialize passing the [SnippetConfig](./x-components.snippetconfig.md)<!-- -->. This installs the plugin and creates the App. There are 3 different ways to do this:

2.1 Using the created installer:

```
           installer.init(snippetConfig)
```
2.2 If the API option is enabled (`createAPI` is `true` in [InstallXOptions](./x-components.installxoptions.md)<!-- -->, or is not present as the default value is `true`<!-- -->) then this init step can be done with the Public API:

```
           window.InterfaceX.init(snippetConfig)
```
2.3 When the script of the project build is loaded it searches for a global `initX` variable that the customer must have in their website. This variable can be a function that returns the [SnippetConfig](./x-components.snippetconfig.md) or an object that contains the [SnippetConfig](./x-components.snippetconfig.md) itself:

```
           window.initX = function() {
                return {
                  instance,
                  env,
                  scope,
                  lang,
                  uiLang,
                  currency,
                  consent,
                  documentDirection
                };
             };
```

```
           window.initX = {
                instance,
                env,
                scope,
                lang,
                uiLang,
                currency,
                consent,
                documentDirection
              };
```

## Constructors

|  Constructor | Modifiers | Description |
|  --- | --- | --- |
|  [(constructor)(options)](./x-components.xinstaller._constructor_.md) |  | Receives the [InstallXOptions](./x-components.installxoptions.md) and merges it with the default fallback options. Also creates the public [XAPI](./x-components.xapi.md)<!-- -->. |

## Properties

|  Property | Modifiers | Type | Description |
|  --- | --- | --- | --- |
|  [options](./x-components.xinstaller.options.md) | <p><code>protected</code></p><p><code>readonly</code></p> | [InstallXOptions](./x-components.installxoptions.md) |  |

## Methods

|  Method | Modifiers | Description |
|  --- | --- | --- |
|  [getSnippetConfig()](./x-components.xinstaller.getsnippetconfig.md) | <code>protected</code> | Getter for the snippet config object. |
|  [init(snippetConfig)](./x-components.xinstaller.init.md) |  | Receives the [snippet config](./x-components.snippetconfig.md) or retrieves it from window.initX and installs the plugin and initializes the Vue application. |
|  [init()](./x-components.xinstaller.init_1.md) |  |  |
|  [normaliseSnippetConfig(snippetConfig)](./x-components.xinstaller.normalisesnippetconfig.md) | <code>protected</code> |  |
|  [normaliseSnippetConfig(snippetConfig)](./x-components.xinstaller.normalisesnippetconfig_1.md) | <code>protected</code> |  |

