How to copy to clipboard in React? II

Chay Auker
Aug 5, 2021

My last blog showed how to copy to the clipboard in React when the user types a value and in this blog I want to show another way when a value has already been stored in the clipboard.

  1. Install npm react-copy-to-clipboard by using the below code:
npm install --save react-copy-to-clipboard

2. Next is to import {CopyRoClipboard} seen within the blue box to the React app

3. Add CopyToClipboard and the button as follow:

4. Then set “text” to the value that is supposed to be copied. Finally, you can use the copy to clipboard button for the value that was stored.

--

--