API / Web Share

Codelab Flow

Introduction

L W Web Share API

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.

Setting up

It is important to note the following checklist for the Web Share API to work;

  1. You must be served over HTTPS
  2. You can only invoke the API in response to a user action, such as a click
  3. You can also share any URL, not just URLs under your website's current scope
  4. 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!

FORK ON GITHUB