Copy To Clipboard

Copies the given text to the clipboard.

CategoryFunctions
AuthorPol Gubau
Since1.0.0
Last Updated2025-03-15
TypeAsync
CompatibilityBrowser

Example

  • Input

    await copyToClipboard('Hello, world!')

    Output:

    true

Return

Returns true if the text was successfully copied, otherwise false.

Type: boolean

Props

NameTypeDefaultRequiredDescription
textstringnullYesThe text to be copied to the clipboard.

Notes

This function uses the `navigator.clipboard.writeText` API to copy text to the clipboard.

Errors

Warning if clipboard is not supported.

Tags

  • clipboard
  • copy
  • text

Related