# clipboard-js

> A web shim to handle clipboard APIs across browsers using a simple Promise API.

Latest version **0.3.6** (published 2017-10-26) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install clipboard-js
pnpm add clipboard-js
yarn add clipboard-js
bun add clipboard-js
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.3.6 |
| Published | 2017-10-26 |
| First published | 2015-05-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/clipboard-js) |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 926 |
| Author | Lucas Garron |
| Maintainers | lgarron |
| Keywords | clipboard, HTML5, copy, copying, cut, paste, execCommand, setData, getData |

## Links

- npm: https://www.npmjs.com/package/clipboard-js
- Repository: https://github.com/lgarron/clipboard.js
- Homepage: https://github.com/lgarron/clipboard.js#readme
- Issues: https://github.com/lgarron/clipboard.js/issues
- npm.io page: https://npm.io/package/clipboard-js

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 0.3.6 (latest) — 2017-10-26
- 0.3.5 — 2017-06-28
- 0.3.4 — 2017-06-28
- 0.3.3 — 2017-02-11
- 0.3.2 — 2016-12-21
- 0.3.1 — 2016-09-23
- 0.3.0 — 2016-09-23
- 0.2.0 — 2015-11-12
- 0.1.2 — 2015-11-12
- 0.1.0 — 2015-05-06

## README

# `clipboard.js`

This library has been superseded by [`clipboard-polyfill`](https://github.com/lgarron/clipboard-polyfill), which works in more browsers.

Here's how to migrate:

# Plain Text

```
// clipboard.js
clipboard.copy("plain text");
```

```
// clipboard-polyfill
clipboard.writeText("plain text");
```

# Rich Text

```
// clipboard.js
clipboard.copy({
  "text/plain": "Fallback markup text.",
  "text/html": "<i>Markup</i> <b>text</b>."
});
```

```
// clipboard-polyfill, similar to async clipboard API
var dt = new clipboard.DT();
dt.setData("text/plain", "Fallback markup text.");
dt.setData("text/html", "<i>Markup</i> <b>text</b>.");
clipboard.write(dt);
```

# DOM element

```
// clipboard.js
clipboard.copy(document.body);
```

```
// clipboard-polyfill, similar to async clipboard API
var dt = new clipboard.DT();
dt.setData("text/plain", document.body.innerText);
dt.setData("text/html", new XMLSerializer().serializeToString(document.body));
clipboard.write(dt);
```

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