React 18, 19 compatible copy-to-clipboard component with TypeScript
npm install react-copy-to-clipboard-tsThis package is a fork of react-copy-to-clipboard. The main differences are:
- React 18, 19 compatibility
- TypeScript support
- ESM and CommonJS support
- Zero dependencies (except copy-to-clipboard)
- Simple and lightweight
``bash`
npm install react-copy-to-clipboard-tsor
yarn add react-copy-to-clipboard-ts
`tsx
// Named import (recommended)
import { CopyToClipboard } from "react-copy-to-clipboard-ts";
// Default import (for migration from react-copy-to-clipboard)
import CopyToClipboard from "react-copy-to-clipboard-ts";
function App() {
return (
);
}
`
| Prop | Type | Description |
| ------ | --------------------------------------- | --------------------------------------------------------- |
| text | string | Text to copy to clipboard |
| onCopy | (text: string, result: boolean) => void | Callback function that will be called when text is copied |
https://t0yohei.github.io/react-copy-to-clipboard-ts/
`bashInstall dependencies
yarn install
MIT