---
title: "Comment by Hrithwik Bharadwaj on \"How to copy to clipboard in JavaScript?\" | Hashnode"
description: "Even I use Clipboard API but with the support for fallback like below, (FB/Instagram browser doesn&#39;t support just clipboard API) async function copyLink ( )"
url: "https://hashnode.com/posts/how-to-copy-to-clipboard-in-javascript/626f7b5da2d355d4df441a5f/comment/6271e052d64dcf11c4fb61da"
---

[Discussion](https://hashnode.com/posts/how-to-copy-to-clipboard-in-javascript/626f7b5da2d355d4df441a5f)

Comment [How to copy to clipboard in JavaScript?](https://hashnode.com/posts/how-to-copy-to-clipboard-in-javascript/626f7b5da2d355d4df441a5f)

[Hrithwik Bharadwaj](https://hashnode.com/@hrithwik)

[May 4, 2022](https://hashnode.com/posts/how-to-copy-to-clipboard-in-javascript/626f7b5da2d355d4df441a5f/comment/6271e052d64dcf11c4fb61da)

Even I use Clipboard API but with the support for fallback like below,

(FB/Instagram browser doesn't support just clipboard API)

```
 async function copyLink(){
      try{
         await navigator.clipboard.writeText(link);
         console.log("Link Copied");
     }
      catch(e){
         copyToClipbordFallback(link);
         console.log("Link Copied");
      }
    }

function copyToClipbordFallback(text){
      const textArea = document.createElement("textarea");
      textArea.value = text;
      document.body.appendChild(textArea);
      textArea.select();
      document.execCommand("copy");
      textArea.remove();
}
```

so this fallback is mainly for FB/IG Browsers and other old browsers

[Tapas Adhikary](https://hashnode.com/@atapas)

[May 4, 2022](https://hashnode.com/posts/how-to-copy-to-clipboard-in-javascript/626f7b5da2d355d4df441a5f/comment/6271e052d64dcf11c4fb61da#reply-6271ec8bf602e011e9f675b6)

Yes that's a good callout [Hrithwik](https://hashnode.com/@hrithwik)
