# clipboard-copy

> Lightweight copy to clipboard for the web

Latest version **4.0.1** (published 2020-11-18) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.1 |
| Published | 2020-11-18 |
| First published | 2017-03-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 632 |
| Author | Feross Aboukhadijeh |
| Maintainers | linusu, feross |
| Keywords | browser, clipboard, clipboard copy, clipboard.js, copy, copy to clipboard, modern browsers, simple |

## Links

- npm: https://www.npmjs.com/package/clipboard-copy
- Repository: https://github.com/feross/clipboard-copy
- Issues: https://github.com/feross/clipboard-copy/issues
- Funding: https://github.com/sponsors/feross
- npm.io page: https://npm.io/package/clipboard-copy

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 4.0.1 (latest) — 2020-11-18
- 4.0.0 — 2020-11-18
- 3.2.0 — 2020-11-03
- 3.1.0 — 2019-07-30
- 3.0.0 — 2019-02-27
- 2.0.1 — 2018-09-12
- 2.0.0 — 2018-03-18
- 1.4.2 — 2018-02-07
- 1.4.1 — 2018-02-03
- 1.4.0 — 2018-02-03
- 1.3.0 — 2018-02-03
- 1.2.1 — 2018-01-27
- 1.2.0 — 2017-04-07
- 1.1.0 — 2017-03-19
- 1.0.1 — 2017-03-18
- … 1 more at https://npm.io/package/clipboard-copy/versions

## README

# clipboard-copy [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url]  [![size][size-image]][size-url] [![javascript style guide][standard-image]][standard-url]

[travis-image]: https://img.shields.io/travis/feross/clipboard-copy/master.svg
[travis-url]: https://travis-ci.org/feross/clipboard-copy
[npm-image]: https://img.shields.io/npm/v/clipboard-copy.svg
[npm-url]: https://npmjs.org/package/clipboard-copy
[downloads-image]: https://img.shields.io/npm/dm/clipboard-copy.svg
[downloads-url]: https://npmjs.org/package/clipboard-copy
[size-image]: https://img.shields.io/bundlephobia/minzip/clipboard-copy
[size-url]: https://bundlephobia.com/result?p=clipboard-copy
[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
[standard-url]: https://standardjs.com

### Lightweight copy to clipboard for the web

The goal of this package is to offer simple copy-to-clipboard functionality in
modern web browsers using the fewest bytes. To do so, this package only supports
modern browsers. No fallback using Adobe Flash, no hacks. Just 30 lines of code.

Unlike other implementations, text copied with `clipboard-copy` is clean and
unstyled. Copied text will not inherit HTML/CSS styling like the page's background
color.

**Supported browsers:** Chrome, Firefox, Edge, Safari.

Works in the browser with [browserify](http://browserify.org/)!

## install

```
npm install clipboard-copy
```

## usage

```js
const copy = require('clipboard-copy')

button.addEventListener('click', function () {
  copy('This is some cool text')
})
```

## API

### `successPromise = copy(text)`

Copy the given text to the user's clipboard. Returns `successPromise`, a promise that resolves if the copy was successful and rejects if the copy failed.

Note: in most browsers, copying to the clipboard is only allowed if `copy()` is
triggered in direct response to a user gesture like a `'click'` or a `'keypress'`.

## comparison to alternatives

- **`clipboard-copy` (this package): [524 B gzipped](https://bundlephobia.com/result?p=clipboard-copy)**
- [`clipboard-js`](https://www.npmjs.com/package/clipboard-js): [1.7 kB gzipped](https://bundlephobia.com/result?p=clipboard-js)
- [`clipboard`](https://www.npmjs.com/package/clipboard): [3.2 kB gzipped](https://bundlephobia.com/result?p=clipboard)

## testing

Testing this module is currently a manual process. Open `test.html` in your web browser and follow the short instructions. The web page will always load the latest version of the module, no bundling is necessary.

## license

MIT. Copyright (c) [Feross Aboukhadijeh](http://feross.org).

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