Socket
Socket
Sign inDemoInstall

react-use-clipboard

Package Overview
Dependencies
7
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-use-clipboard

React hook that provides copy to clipboard functionality.


Version published
Weekly downloads
59K
decreased by-1.71%
Maintainers
1
Install size
30.9 kB
Created
Weekly downloads
 

Changelog

Source

1.0.9

Patch Changes

  • b51078d: Rename the default export function to useClipboard instead of useCopyClipboard for consistency with the package name.

Readme

Source

📋 react-use-clipboard

NPM version Test build status Bundle size Bundle size

A React Hook that provides copy to clipboard functionality.

Install

You can install react-use-clipboard with NPM or Yarn.

npm install react-use-clipboard
yarn add react-use-clipboard

Usage

Here's how to use react-use-clipboard:

import useClipboard from "react-use-clipboard";

function App() {
  const [isCopied, setCopied] = useClipboard("Text to copy");

  return (
    <button onClick={setCopied}>
      Was it copied? {isCopied ? "Yes! 👍" : "Nope! 👎"}
    </button>
  );
}

You can reset the isCopied value after a certain amount of time with the successDuration option.

import useClipboard from "react-use-clipboard";

function App() {
  const [isCopied, setCopied] = useClipboard("Text to copy", {
    // `isCopied` will go back to `false` after 1000ms.
    successDuration: 1000,
  });

  return (
    <button onClick={setCopied}>
      Was it copied? {isCopied ? "Yes! 👍" : "Nope! 👎"}
    </button>
  );
}

This package only works in versions of React that support Hooks.

Keywords

FAQs

Last updated on 10 Oct 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc