Web Share API Tutorial
Now, broswer can share items as APP, using Web Share API
API is pretty simple, use navigator.share
to detect browser ability, use the same way as Promise.
if (navigator.share) {
navigator
.share({
title: "Share my blog",
text: "Web development tutorial blogs",
url: "https://justforuse.github.io/blog/en-us/"
})
<!-- select item callback -->
.then(() => console.log("thanks for share"))
<!-- cancel share callback -->
.catch(error => console.log("error", error));
}
Online demo, access with Chrome with mobile:
See the Pen by (@justforuse) on CodePen.
But its compatibility is bad now, just about 45% around the world.
π Please leave your comment if you like this.π