---
url: /api/reference/modules/functions/addWxtPlugin.md
---

[API](../../packages.md) / [modules](../index.md) / addWxtPlugin

# Function: addWxtPlugin()

> **addWxtPlugin**(`wxt`, `plugin`, `apply?`): `void`

Source: [packages/wxt/src/modules/index.ts:147](https://github.com/wxt-dev/wxt/blob/972fe87151a882800f7855a3951c70cef4441659/packages/wxt/src/modules/index.ts#L147)

Add a runtime plugin to the project. In each entrypoint, before executing the
`main` function, plugins are executed.

## Parameters

### wxt

[`Wxt`](../../wxt/interfaces/Wxt.md)

The wxt instance provided by the module's setup function.

### plugin

`string`

An import from an NPM module, or an absolute file path to the
file to load at runtime.

### apply?

(`entrypoint`) => `boolean`

Optional. Return `true` to load the plugin in the given
entrypoint. Defaults to loading the plugin in every entrypoint.

## Returns

`void`

## Example

```ts
export default defineWxtModule((wxt) => {
    addWxtPlugin(
      wxt,
      'wxt-module-analytics/background-plugin',
      (entrypoint) => entrypoint.type === 'background',
    );
  });
```

***

Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/)
