dev-resources.site
for different kinds of informations.
What’s your excuse for not using the web share API?
Published at
11/16/2024
Categories
socialmedia
sharing
webstandards
Author
codepo8
Author
7 person written this
codepo8
open
The WebShare API is so easy to use, it is a crime people don't use it more. Instead, we have tons of dead "share on $thing" buttons on the web. Many of which spy on your users and lots of them that started as Wordpress plugins but now are security concerns. Instead of guessing how your visitors want to share the current URL or a file you provide, you can call the API and they can pick their favourite:
This is the code and you can also check it on codepen:
let shareButton = document.querySelector('button');
shareButton.addEventListener("click", async () => {
try {
await navigator.share({ title: "Example Page", url: "" });
console.log("Data was shared successfully");
} catch (err) {
console.error("Share failed:", err.message);
}
});
An empty url means the current document is shared. You can also add a different title, which makes more sense than "Example page".
sharing Article's
30 articles in total
What’s your excuse for not using the web share API?
currently reading
Info card sharing service (free, no login required)
read article
Building a Tech Community from Scratch
read article
I Taught GIT to High School Students
read article
😮💨Saya Menyesal Beli Domain my.id
read article
<p *>Demystifying the Angular Structural Directives in a nutshell</p>
read article
Why I Like Writing Technical Blogs
read article
Add GitHub repository info, GitHub pages links and latest commits to any page using github-include
read article
Adding a "share to mastodon" link to any web site
read article
How do you differentiate Junior/Mid/Senior developer?
read article
Let anyone, anywhere, edit your static sites
read article
Digital Printing and Dev Printing: Are they the same?
read article
My “What is Coding?” Class
read article
Announcing Public Sharing: Share Your Drafts with the World on Contenda!
read article
sNationalDaysToday.com - Unite people to celebrate everyday
read article
Bugblogging
read article
The impact of sharing sessions in an engineering team
read article
Top 5 Things I Actually Like About Top {X} Posts
read article
Partnering with Google on web.dev
read article
Resource Helper website for easy access to daily usable links
read article
I make a list of free stuff/services for developers
read article
Sharing Local Server with Local Network (XAMPP)
read article
geek week local
read article
Adding RSS feed to my Nuxt & Storyblok blog
read article
What online image sharing service do you use?
read article
A Software to publish good code examples
read article
hackershare: Social bookmarking reinvented!
read article
Sharing keyboard & mouse across devices
read article
1 year experience, enjoying learning, but unfavorable atmosphere. Should I continue or not?
read article
Why I decided to start blogging and why we all should 🙌
read article
Featured ones: