How to build a web share with an image in react js

You can use the Web Share API in your react js website to share text, URL, images, and files. The Web Share API allows web applications to share image
web share Api




Important questions related to this

How to Use the Web Share API?

How do I share an image with text on Whatsapp in react js?

How to share an image with navigator.share()

web share Api
Mobile View

web share Api
Desktop View


A very important function of any web application is to allow the user to share it, be it a blog, a post on social networks, or a news article. The use of social networks is essential both for the dissemination of information and for business success. Here we discuss how easy it is to create a small component that uses a browser API to provide sharing functionality with a native feel, regardless of whether the user is on iOS or Android.

You can use the Web Share API in your React.js web application to share text, URLs, and files. The Web Share API allows web applications to share text, URLs, and files with other applications installed on the device in the same way as native applications.


Web Share API has some limitations:

  • It can only be used on a site that supports HTTPS.
  • It does not work in some browsers like android webview
  • Some images do not fetch during production time

onClick Function Souce Code Below





const onClickShare =  () =>{
    fetch('image_link_here')
  .then((res) => res.blob())
  .then((myBlob) => {
    console.log(myBlob);
    const myFile = new File([myBlob], "image.jpeg", {
      type: myBlob.type,
    });
    
    console.log(myFile);
    // logs: Blob { size: 1024, type: "image/jpeg" }
    var filesArray = [myFile];

    if(navigator.canShare && navigator.canShare({ files: filesArray })) {
      navigator.share({
        text: 'Earn 10 Points For Referring This App To Your Friends By Using This Link.',
        files: filesArray,
        title: ' Referral',
        url: `https://www.xxxxxxx.com/signup?ref=${referralId}`
      });
    }
  });
   }
web share image web share api with image share web image on whatsapp react share image whatsapp how to use react share react facebook share image web share image social media integration in react js can i use web share api react share facebook examples react instagram share navigator.share image example navigator.share with image navigator share api navigator.share js navigator share files web share api share image navigator.share not working ng-navigator-share window.navigator.share web share api javascript navigator.share undefined navigator.share example navigator.share react navigator.share mdn navigator share image example web share api share image navigator share angular react navigator share navigator share example vue navigator share navigator share api web share api codepen navigator.share is not a function navigator.share image navigator.share example navigator.share webview navigator.share files example navigator.share in react navigator.share is undefined navigator.share browser support navigator.share javascript navigator.share alternative navigator.share android webview navigator.share android navigator.share angular navigator.share api navigator.share with image navigator share price asx the navigator share price navigator.share blob navigator share base64 navigator.share caniuse navigator.share chrome navigator share codepen navigator.share canvas navigator can share navigator company share price navigator.can share is not a function navigator company share navigator.share demo navigator.share desktop navigator share disclosure navigator share permission denied simmons navigator share disclosure login navigator.share image example content navigator external share ibm content navigator external share navigator.share files navigator.share facebook navigator.share firefox navigator.share files ios navigator.share pdf file if navigator.share navigator gas share price navigator global share price asx navigator global share price ng-navigator-share navigator holdings share price navigator holdings share html navigator share navigator.share ios navigator.share instagram navigator share icon navigator.share can i use can i use navigator.share navigator.share jquery js navigator.share navigator.share js navigator.share() navigator share api navigator.share mdn navigator share localhost sales navigator share list navigator trading limited share price navigator resources limited share price navigator resources ltd share price netscape navigator market share navigator credit union membership share charity navigator share the meal navigator.share not working navigator.share not working on ios navigator.share options charity navigator share our strength file share navigator online avepoint file share navigator online navigator.share polyfill navigator share price navigator.share pdf navigator.share react share navigator review navigator resources share price navigator.share safari navigator share screen navigator slideshare simmons navigator share disclosure navigator.share typescript navigator.share text navigator share test typeerror navigator.share is not a function navigator.share undefined navigator.share url navigator share video vue navigator share window.navigator.share navigator share files