JSFiddle - React, Tailwind, and code Playground

HTML

<a href="https://example.com?utm_source=btn_share" class="btn-share" target="_blank">
    Share on Facebook
</a>

JavaScript

$(".btn-share").click(function(e){
    // Web Share API
    if (navigator.share && !$(this).prop('error')){
        e.preventDefault();
        navigator.share({
            title: 'This is example website',
            url: 'https://example.com'
        }).catch(() => {
            $(this).prop('error', true);
            $(this).click();
        });
    } else {
        $(this).prop('error', false);
    }
});