# JavaScript Tips: Web share Api

```bash
const shareData = {
  title: "au.mirza",
  url: "https://www.instagram.com/au.mirza"
};

const btn = document.getElementById("share");
btn.addEventListener("click", shareHandler);

function shareHandler() {
  if (navigator.share && navigator.canShare(shareData)) {
    navigator
      .share(shareData)
      .then(alert("Thankyou for sharing."))
      .catch(webConsole);
  } else {
    webConsole(
      "Either your browser is incompatible or the data is not shareable"
    );
  }
}
```

## Compatibility

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1675961821131/fd301924-04a6-4530-a5a3-48033cdbc724.png align="center")

## Preview

This preview is taken from Edge running on Android 11.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1675961829142/8f71832c-c3ac-4fc0-b44a-ad9326c353d5.jpeg align="center")
