Home
Softono

Use Clippy

Open source MIT TypeScript
176
Stars
11
Forks
18
Issues
1
Watchers
3 years
Last Commit

 About Use Clippy

React Hook for reading from and writing to the user's clipboard.

Platforms

Web Self-hosted

Languages

TypeScript

Need Help Installing Use Clippy?

We provide expert installation service for this software. Our team will install, configure, and secure Use Clippy on your server. plans start at just $30.

Use Clippy

View on GitHub

useClippy Tweet version minified size minzipped size downloads build

useClippy is a TypeScript-friendly React hook for reading from and writing to the user's clipboard.

Not to be confused with Microsoft Office's assistant, Clippy. 📎

Demo

You can see use-clippy in action via GitHub Pages, which hosts the demo directory.

Install

  • npm install use-clippy or
  • yarn add use-clippy

Use

useClippy() returns a tuple analogous to useState, where the first item is the clipboard contents and the second item is a function for setting the clipboard contents.

import React from 'react';
import useClippy from 'use-clippy';

export default function MyComponent() {

  // clipboard is the contents of the user's clipboard.
  // setClipboard('new value') wil set the contents of the user's clipboard.
  const [clipboard, setClipboard] = useClippy();

  return (
    <div>

      {/* Button that demonstrates reading the clipboard. */}
      <button
        onClick={() => {
          alert(`Your clipboard contains: ${clipboard}`);
        }}
      >
        Read my clipboard
      </button>

      {/* Button that demonstrates writing to the clipboard. */}
      <button
        onClick={() => {
          setClipboard(`Random number: ${Math.random()}`);
        }}
      >
        Copy something new
      </button>
    </div>
  );
}

Sponsor đź’—

If you are a fan of this project, you may become a sponsor via GitHub's Sponsors Program.