JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 14
  • Score
    100M100P100Q39652F
  • License MIT

A next.js-friendly clipboard utility with support for text, JSON, HTML, and images.

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (next-clippy) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Next Clipboard

    Next Clipboard is a lightweight React hook that enables seamless text copying functionality in Next.js applications.

    Features

    • Copy text to the clipboard effortlessly.
    • Provides a copied state to track the copying status.
    • Optimized for Next.js and modern React development.

    Installation

    Use npm or yarn to install:

    npm install next-clipboard

    or

    yarn add next-clipboard

    Usage

    Import and use the useClipboard hook in your component:

    import { useClipboard } from "next-clipboard";
    
    export default function CopyComponent() {
        const { copy, copied } = useClipboard();
    
        return (
            <div>
                <button onClick={() => copy("Hello, World!")}>Copy Text</button>
                {copied && <span>Copied!</span>}
            </div>
        );
    }

    API

    useClipboard()

    Returns an object containing:

    • copy(text: string): Copies the provided text to the clipboard.
    • copied: boolean: Indicates whether the text was recently copied.

    Running Tests

    Ensure jest and @testing-library/react-hooks are installed. Then run:

    npm test

    Contributing

    Contributions are welcome! Feel free to fork the repository and submit a pull request.

    License

    This project is licensed under the MIT License.