Browser · @vueuse/core v15.0.0 · Reviewed

useClipboard

Copy a value with the browser clipboard API and expose whether copying is supported or complete.

App.vueVue SFCOpen in Vue Playground ↗
Live preview

Edit the code and the preview updates as you type.

What it does

A coupon or invite code should copy from one button, with clear feedback when the browser accepts the clipboard request.

The playground is a small, runnable example. Change the code and try the interaction before copying it into an app.

The code

Vue · Composition API
const source = ref('SAVE10')
const { copy, copied, isSupported } = useClipboard({ source })
// Call copy() from a user click handler.

Where you'd use it

  • Copying coupon and invite codes
  • Copying a share link
  • Copying a generated API example

In Nuxt (and other gotchas)

Clipboard access is browser-only and commonly requires a secure context and a user gesture. Check isSupported before rendering an enabled action; do not read navigator.clipboard during SSR.

When not to use it

For copying a value that never changes, a tiny button with the native Clipboard API may be enough. Never report success before the asynchronous copy operation resolves.

Links

Need a hand with your Vue or Nuxt app?

Related functions