Gathering detailed insights and metrics for vue-clipboard3
Gathering detailed insights and metrics for vue-clipboard3
Gathering detailed insights and metrics for vue-clipboard3
Gathering detailed insights and metrics for vue-clipboard3
npm install vue-clipboard3
Typescript
Module System
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
142 Stars
13 Commits
13 Forks
1 Watchers
1 Branches
1 Contributors
Updated on Jul 02, 2025
Latest Version
2.0.0
Package Id
vue-clipboard3@2.0.0
Unpacked Size
12.25 kB
Size
4.17 kB
File Count
17
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
3
Easily copy to clipboard in Vue 3 (composition-api) using clipboard.js 📋
Thanks to vue-clipboard2 for inspiration!
yarn add vue-clipboard3
or
npm install --save vue-clipboard3
For use with Vue 3 and the Composition API. I decided to keep in line with the Vue 3 spirit and not make a directive out of this (if you want a vue directive, please make a pull request). I think it makes more sense and provides more clarity to just use this as a method in the setup()
function.
Keep it simple.
1<template lang="html"> 2 <button @click="copy">Copy!</button> 3</template> 4 5<script lang="ts"> 6import { defineComponent } from '@vue/composition-api' 7import useClipboard from 'vue-clipboard3' 8 9export default defineComponent({ 10 setup() { 11 const { toClipboard } = useClipboard() 12 13 const copy = async () => { 14 try { 15 await toClipboard('Any text you like') 16 console.log('Copied to clipboard') 17 } catch (e) { 18 console.error(e) 19 } 20 } 21 22 return { copy } 23 } 24}) 25</script>
1<template lang="html"> 2 <div> 3 <input type="text" v-model="text"> 4 <button @click="copy">Copy!</button> 5 </div> 6</template> 7 8<script lang="ts"> 9import { defineComponent, ref } from '@vue/composition-api' 10import useClipboard from 'vue-clipboard3' 11 12export default defineComponent({ 13 setup() { 14 const { toClipboard } = useClipboard() 15 16 const text = ref('') 17 18 const copy = async () => { 19 try { 20 await toClipboard(text.value) 21 console.log('Copied to clipboard') 22 } catch (e) { 23 console.error(e) 24 } 25 } 26 27 return { copy, text } 28 } 29}) 30</script>
1useClipboard(options: Options)
1interface Options { 2 /** Fixes IE by appending element to body. Defaults to true. */ 3 appendToBody: boolean 4}
returns an object with a single key: toClipboard
1toClipboard(text: string, container?: HTMLElement)
requires that you pass in at least one argument that is a string. This is the text to be copied to the clipboard. The second optional argument is a html element that will be used as the container internally when using clipboard.js.
PRs and issues welcome!
1git clone https://github.com/JamieCurnow/vue-clipboard3.git 2cd vue-clipboard3 3yarn install 4yarn watch
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/12 approved changesets -- 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
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
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