How to Copy Text to Clipboard

2023.05.11

const copyUrl = () => {
navigator.clipboard
.writeText(window.location.href)
.then(() => message.success('Successfully copied.'))
.catch(() => message.error('Copy link failed.'));
};

return (
<Button
className={cx('button')}
type="default"
shape="round"
onClick={copyUrl}
>
Share your link
</Button>
)

--

--