Web Share API allows you easily trigger the native Android share dialog, passing either a URL or text or both to share. Supported in Chrome for Mobile and Microsoft Edge latest version.
API / Web Share
Codelab Flow
Introduction
L
W
Web Share API
Setting up
It is important to note the following checklist for the Web Share API to work;
- You must be served over HTTPS
- You can only invoke the API in response to a user action, such as a click
- You can also share any URL, not just URLs under your website's current scope
- And you may also share text without a URL
Define the data object to be shared
const data = {
// Title of what to share
title: `Some title..`,
// Text to share
text: `Some text...`,
// Url to share...
url: 'https://pwafire.org',
};
Call the share method on pwa
pwa.Share(data);
Demo in action
While on your phone or on desktop but using Microsoft Edge, click the button below to demo our Web Share add-on!