Gathering detailed insights and metrics for react-copy-to-clipboard
Gathering detailed insights and metrics for react-copy-to-clipboard
Gathering detailed insights and metrics for react-copy-to-clipboard
Gathering detailed insights and metrics for react-copy-to-clipboard
Copy-to-clipboard React component
npm install react-copy-to-clipboard
Typescript
Module System
Node Version
NPM Version
JavaScript (91.64%)
CSS (8.36%)
Total Downloads
276,207,911
Last Day
61,517
Last Week
1,396,275
Last Month
5,938,835
Last Year
65,614,257
MIT License
2,359 Stars
525 Commits
128 Forks
18 Watchers
2 Branches
19 Contributors
Updated on May 07, 2025
Minified
Minified + Gzipped
Latest Version
5.1.0
Package Id
react-copy-to-clipboard@5.1.0
Unpacked Size
39.68 kB
Size
10.24 kB
File Count
9
NPM Version
8.3.2
Node Version
16.13.2
Cumulative downloads
Total Downloads
Last Day
10.5%
61,517
Compared to previous day
Last Week
-5.6%
1,396,275
Compared to previous week
Last Month
-0%
5,938,835
Compared to previous month
Last Year
15.7%
65,614,257
Compared to previous year
2
1
29
Copy to clipboard React component
Based on copy-to-clipboard
Would try to use execCommand with fallback to IE specific clipboardData interface and finally, fallback to simple prompt with proper text content & 'Copy to clipboard: Ctrl+C, Enter'
1npm install --save react-copy-to-clipboard
Don't forget to manually install peer dependencies (react
) if you use npm@3.
1<script src="https://unpkg.com/react@16.0.0/umd/react.production.min.js"></script> 2<script src="https://unpkg.com/react-copy-to-clipboard/build/react-copy-to-clipboard.js"></script> 3(Module exposed as `CopyToClipboard`)
http://nkbt.github.io/react-copy-to-clipboard
http://codepen.io/nkbt/pen/eNPoQv
1import React from 'react'; 2import ReactDOM from 'react-dom'; 3import {CopyToClipboard} from 'react-copy-to-clipboard'; 4 5class App extends React.Component { 6 state = { 7 value: '', 8 copied: false, 9 }; 10 11 render() { 12 return ( 13 <div> 14 <input value={this.state.value} 15 onChange={({target: {value}}) => this.setState({value, copied: false})} /> 16 17 <CopyToClipboard text={this.state.value} 18 onCopy={() => this.setState({copied: true})}> 19 <span>Copy to clipboard with span</span> 20 </CopyToClipboard> 21 22 <CopyToClipboard text={this.state.value} 23 onCopy={() => this.setState({copied: true})}> 24 <button>Copy to clipboard with button</button> 25 </CopyToClipboard> 26 27 {this.state.copied ? <span style={{color: 'red'}}>Copied.</span> : null} 28 </div> 29 ); 30 } 31} 32 33const appRoot = document.createElement('div'); 34document.body.appendChild(appRoot); 35ReactDOM.render(<App />, appRoot);
text
: PropTypes.string.isRequiredText to be copied to clipboard
onCopy
: PropTypes.funcOptional callback, will be called when text is copied
onCopy(text, result)
result (bool)
: Returns true
if copied successfully, else false
.
options
: PropTypes.shape({debug: bool, message: string})Optional copy-to-clipboard options.
See API docs for details
children
: PropTypes.node.isRequiredCopyToClipboard is a simple wrapping component, it does not render any tags, so it requires the only child element to be present, which will be used to capture clicks.
1<CopyToClipboard text="Hello!"> 2 <button>Copy to clipboard</button> 3</CopyToClipboard>
Currently is being developed and tested with the latest stable Node 8
on OSX
.
To run example covering all CopyToClipboard
features, use yarn start
, which will compile example/Example.js
1git clone git@github.com:nkbt/react-copy-to-clipboard.git 2cd react-copy-to-clipboard 3yarn install 4yarn start 5 6# then 7open http://localhost:8080
1# to run ESLint check 2yarn lint 3 4# to run tests 5yarn test 6 7# to run end-to-end tests 8# first, run `selenium/standalone-firefox:3.4.0` docker image 9docker run -p 4444:4444 selenium/standalone-firefox:3.4.0 10# then run test 11yarn e2e
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 1/10 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
46 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-05-26
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More