> For the complete documentation index, see [llms.txt](https://stash-it.gitbook.io/stash-it/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stash-it.gitbook.io/stash-it/api/cacheinstance/registerplugins-plugins.md).

# registerPlugins(plugins)

Registers plugins and returns new instance of self (cacheInstance) extended with functionalities provided by plugins.

### **Arguments**

1. `plugins` *(array)*: Array of [plugins](/stash-it/plugins.md).

### **Returns**

*(*[*cacheInstance*](/stash-it/api/cacheinstance.md)*)*: A new instance of cacheInstance. New instance of cache, like the original one, is immutable (using [Object.freeze](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze)).

### Throws

1. When plugins are not passed as an array.
2. When any of the plugins won't contain either [`hooks`](/stash-it/plugins/hooks.md) or [`createExtensions`](/stash-it/plugins/createextensions.md) method.
3. When any of the plugins will try do add a method that already exists (which would overwrite it).

### **Example**

```javascript
// assuming that you already have cache instance and some plugins prepared
// plugin adds additional method `foo`
const cacheWithPlugins = cache.registerPlugins([ plugin ]);

cacheWithPlugins === cache; // false

typeof cacheWithPlugins.foo; // function
typeof cache.foo; // undefined
```
