# @swup/plugin

> Base class for creating swup plugins

Latest version **4.0.0** (published 2023-09-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install @swup/plugin
pnpm add @swup/plugin
yarn add @swup/plugin
bun add @swup/plugin
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2023-09-19 |
| First published | 2019-04-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 48 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Georgy Marchuk |
| Maintainers | hirasso, daun, gmrchk |

## Links

- npm: https://www.npmjs.com/package/@swup/plugin
- Repository: https://github.com/swup/plugin
- Homepage: https://github.com/swup/plugin#readme
- Issues: https://github.com/swup/plugin/issues
- npm.io page: https://npm.io/package/@swup/plugin

## Dependencies (1)

- [swup](https://npm.io/package/swup.md) ^4.0.0

## Recent versions

- 4.0.0 (latest) — 2023-09-19
- 3.0.0-rc.27 (next) — 2023-07-25
- 3.0.1 — 2023-08-29
- 3.0.0 — 2023-07-26
- 3.0.0-rc.26 — 2023-07-25
- 3.0.0-rc.25 — 2023-07-20
- 3.0.0-rc.24 — 2023-07-20
- 3.0.0-rc.23 — 2023-07-20
- 3.0.0-rc.22 — 2023-07-17
- 3.0.0-rc.1 — 2023-07-03
- 2.0.3 — 2023-06-03
- 2.0.2 — 2023-01-27
- 2.0.1 — 2023-01-24
- 2.0.0 — 2023-01-18
- 2.0.0-rc.3 — 2023-01-18
- … 7 more at https://npm.io/package/@swup/plugin/versions

## README

# Swup Base Plugin

Base class for creating [swup](https://swup.js.org) plugins.

## Creating a Plugin

To create a new plugin, use the official [swup plugin template](https://github.com/swup/plugin-template).
It comes with detailed instructions and the required tooling.

## Usage

Import the base class and extend your plugin from it.

```js
import Plugin from '@swup/plugin';

export default class PluginName extends Plugin {
  name = 'PluginName';
  mount() {}
  unmount() {}
}
```

## Development

The official [swup command-line interface](https://github.com/swup/cli) has commands to help with
bundling and linting plugins.

```sh
npm install --save-dev @swup/cli
```

### Bundling

Bundle the plugin for production using [microbundle](https://github.com/developit/microbundle),
creating ESM and UMD builds.

```bash
# Bundle and transpile plugin code for distribution
swup package:bundle

# Bundle plugin code in watch mode
swup package:dev
```

### Linting & formatting

Lint the plugin code using [prettier](https://prettier.io/) and swup's recommended rules.

```bash
# Lint plugin code
swup package:lint

# Fix and format any lint errors
swup package:format
```

### Package info

Check that the plugin's package.json file contains the required information for microbundle:
input, output, export map, amd name, etc.

```bash
# Check plugin package info
swup package:check
```

---
_Source: https://npm.io/package/@swup/plugin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
