DEV Community

Cover image for Web Share API & Sharer URLs
James Miller
James Miller

Posted on • Originally published at jamesmiller.blog on

Web Share API & Sharer URLs

Social sharing is a standard in our daily lives nowadays and is often a requirement for projects I work on. I’ve recently stumbled upon a nice easy way to include it using Web Share API and Social Share URLs – which I wanted to make a note of going forward.

WebShare API is a code standard that allows the sharing of content (url / image / text) on any installed social media or messaging app. This is done via the native browser share interface of the device you’re opening it on (this is currently only compatible with Mobile Devices and Safari on Mac OS).

Sharer URLs are links that allow the sharing of content (url / image / text) on a social media platform that the url is written for. In this example this is done for Facebook, Twitter, WhatsApp and Pinterest.

web share api
Visual explanation of the code I’ve written below, that allows you to play with in your browser. It demonstrates social sharing implemented with Web Share API if you’re viewing this page on a compatible device (e.g Mobile Devices / safari on Mac OS), or Sharer Urls if you’re viewing on a device which is not compatible with Web Share API (e.g most laptops).

To edit the code, open the HTML, CSS or JS tabs – or just have a cheeky click around on the Result tab! Have fun with Web Share API and enjoy 😀

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay