use-to-clipboard
v1.0.1
Published
Copy text to the clipboard using useToClipboard.
Downloads
6
Readme
use-to-clipboard
Copy text to the clipboard using useToClipboard.
Installation
To install the package, use npm:
pnpm add use-to-clipboard
yarn install use-to-clipboard
npm install use-to-clipboard
Usage
import React, { useState } from "react";
import { useToClipboard } from "use-to-clipboard";
const CopyTextComponent: React.FC = () => {
const [text, setText] = useToClipboard();
return (
<div>
<button onClick={() => setText("Hello, World!")}>
Copy to Clipboard
</button>
{text && <p>Copied: {text}</p>}
</div>
);
};
export default CopyTextComponent;
tsup
Bundle your TypeScript library with no config, powered by esbuild.
https://tsup.egoist.dev/
How to use this
- install dependencies
# pnpm
$ pnpm install
# yarn
$ yarn install
# npm
$ npm install
- Add your code to
src
- Add export statement to
src/index.ts
- Test build command to build
src
. Once the command works properly, you will seedist
folder.
# pnpm
$ pnpm run build
# yarn
$ yarn run build
# npm
$ npm run build
- Publish your package
$ npm publish
test package
https://www.npmjs.com/package/use-to-clipboard