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
copiedstate to track the copying status. - Optimized for Next.js and modern React development.
Installation
Use npm or yarn to install:
npm install next-clippyor
yarn add next-clippyUsage
Import and use the useClipboard hook in your component:
import { useClipboard } from "next-clippy";
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 testContributing
Contributions are welcome! Feel free to fork the repository and submit a pull request.
License
This project is licensed under the MIT License.