Web Share API

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The Web Share API provides a mechanism for sharing text, links, files, and other content to an arbitrary share target selected by the user.

Note: This API is not available in Web Workers (not exposed via WorkerNavigator).

Note: This API should not be confused with the Web Share Target API, which allows a website to specify itself as a share target.

Concepts and usage

The Web Share API allows a site to share text, links, files, and other content to user-selected share targets, utilizing the sharing mechanisms of the underlying operating system. These share targets typically include the system clipboard, email, contacts or messaging applications, and Bluetooth or Wi-Fi channels.

The API has just two methods. The navigator.canShare() method may be used to first validate whether some data is "shareable", prior to passing it to navigator.share() for sending.

The navigator.share() method invokes the native sharing mechanism of the underlying operating system and passes the specified data. It requires transient activation, and hence must be triggered off a UI event like a button click. Further, the method must specify valid data that is supported for sharing by the native implementation.

The Web Share API is gated by the web-share Permissions Policy. If the policy is supported but has not been granted, both methods will indicate that the data is not shareable.

Interfaces

Extensions to other interfaces

Returns a boolean indicating whether the specified data is shareable.

Returns a Promise that resolves if the passed data was successfully sent to a share target. This method must be called on a button click or other user activation (requires transient activation).

Example

The code below shows how you can share a link using navigator.share(), triggered off a button click.

js
const shareData = {
  title: "MDN",
  text: "Learn web development on MDN!",
  url: "https://developer.mozilla.org",
};

const btn = document.querySelector("button");
const resultPara = document.querySelector(".result");

// Share must be triggered by "user activation"
btn.addEventListener("click", async () => {
  try {
    await navigator.share(shareData);
    resultPara.textContent = "MDN shared successfully";
  } catch (err) {
    resultPara.textContent = `Error: ${err}`;
  }
});

The above example is taken from our Web share test (see the source code). You can also see this as a live example in navigator.share().

Specifications

Specification
Web Share API

Browser compatibility

api.Navigator.share

desktop mobile server
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Node.js
share
Chrome – Partial support
Chrome 89 – 127 (Release date: 2021-03-02)
footnote Partial support
footnote Only supported on ChromeOS and Windows, see bug 40542648 and bug 40729163.
Chrome – Full support
Chrome 128 (Release date: 2024-08-20)
footnote Full support
Edge – Partial support
Edge 81 – 92 (Release date: 2020-04-13)
footnote Partial support
footnote Only supported on Windows.
Edge – Full support
Edge 93 (Release date: 2021-09-02)
footnote Full support
Firefox – No support
Firefox 71 (Release date: 2019-12-10)
disabled
disabled From version 71 users must explicitly set the dom.webshare.enabled preference to true. To change preferences in Firefox, visit about:config.
Opera – Partial support
Opera 75 – 113 (Release date: 2021-03-24)
footnote Partial support
footnote Only supported on ChromeOS and Windows, see bug 40542648 and bug 40729163.
Opera – Full support
Opera 114 (Release date: 2024-09-25)
footnote Full support
Safari – Full support
Safari 12.1 (Release date: 2019-03-25)
footnote Full support
Chrome Android – Full support
Chrome Android 61 (Release date: 2017-09-05)
footnote Full support
Firefox for Android – Full support
Firefox for Android 79 (Release date: 2020-07-28)
footnote Full support
Opera Android – Full support
Opera Android 48 (Release date: 2018-11-08)
footnote Full support
Safari on iOS – Full support
Safari on iOS 12.2 (Release date: 2019-03-25)
footnote Full support
Samsung Internet – Full support
Samsung Internet 8 (Release date: 2018-07-18)
footnote Full support
WebView Android – No support
WebView Android
footnote
footnote See bug 40540400
WebView on iOS – Full support
WebView on iOS 12.2 (Release date: 2019-03-25)
footnote Full support
Node.js – No support
Node.js
footnote No support
data.files parameter
Chrome – Full support
Chrome 89 (Release date: 2021-03-02)
footnote Full support
Edge – Full support
Edge 81 (Release date: 2020-04-13)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 75 (Release date: 2021-03-24)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Chrome Android – Full support
Chrome Android 76 (Release date: 2019-07-30)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – Full support
Opera Android 54 (Release date: 2019-10-18)
footnote Full support
Safari on iOS – Full support
Safari on iOS 14 (Release date: 2020-09-16)
footnote Full support
Samsung Internet – Full support
Samsung Internet 11 (Release date: 2019-12-05)
footnote Full support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – Full support
WebView on iOS 14 (Release date: 2020-09-16)
footnote Full support
Node.js – No support
Node.js
footnote No support
data.text parameter
Chrome – Full support
Chrome 89 (Release date: 2021-03-02)
footnote Full support
Edge – Full support
Edge 81 (Release date: 2020-04-13)
footnote Full support
Firefox – No support
Firefox 71 (Release date: 2019-12-10)
disabled
disabled From version 71 users must explicitly set the dom.webshare.enabled preference to true. To change preferences in Firefox, visit about:config.
Opera – Full support
Opera 75 (Release date: 2021-03-24)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Chrome Android – Full support
Chrome Android 76 (Release date: 2019-07-30)
footnote Full support
Firefox for Android – Full support
Firefox for Android 79 (Release date: 2020-07-28)
footnote Full support
Opera Android – Full support
Opera Android 54 (Release date: 2019-10-18)
footnote Full support
Safari on iOS – Full support
Safari on iOS 14 (Release date: 2020-09-16)
footnote Full support
Samsung Internet – Full support
Samsung Internet 11 (Release date: 2019-12-05)
footnote Full support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – Full support
WebView on iOS 14 (Release date: 2020-09-16)
footnote Full support
Node.js – No support
Node.js
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
See implementation notes.
User must explicitly enable this feature.
Has more compatibility info.

api.Navigator.canShare

desktop mobile server
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Node.js
canShare
Chrome – Partial support
Chrome 89 – 127 (Release date: 2021-03-02)
footnote Partial support
footnote Only supported on ChromeOS and Windows, see bug 40542648 and bug 40729163.
Chrome – Full support
Chrome 128 (Release date: 2024-08-20)
footnote Full support
Edge – Partial support
Edge 81 – 92 (Release date: 2020-04-13)
footnote Partial support
footnote Only supported on Windows.
Edge – Full support
Edge 93 (Release date: 2021-09-02)
footnote Full support
Firefox – No support
Firefox 96 (Release date: 2022-01-11)
disabled
disabled From version 96 users must explicitly set the dom.webshare.enabled preference to true. To change preferences in Firefox, visit about:config.
Opera – Partial support
Opera 75 – 113 (Release date: 2021-03-24)
footnote Partial support
footnote Only supported on ChromeOS and Windows, see bug 40542648 and bug 40729163.
Opera – Full support
Opera 114 (Release date: 2024-09-25)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Chrome Android – Full support
Chrome Android 75 (Release date: 2019-06-04)
footnote Full support
Firefox for Android – Full support
Firefox for Android 96 (Release date: 2022-01-11)
footnote Full support
Opera Android – Full support
Opera Android 54 (Release date: 2019-10-18)
footnote Full support
Safari on iOS – Full support
Safari on iOS 14 (Release date: 2020-09-16)
footnote Full support
Samsung Internet – Full support
Samsung Internet 11 (Release date: 2019-12-05)
footnote Full support
WebView Android – No support
WebView Android
footnote
footnote See bug 40540400
WebView on iOS – Full support
WebView on iOS 14 (Release date: 2020-09-16)
footnote Full support
Node.js – No support
Node.js
footnote No support
data.files parameter
Chrome – Full support
Chrome 89 (Release date: 2021-03-02)
footnote Full support
Edge – Full support
Edge 81 (Release date: 2020-04-13)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 75 (Release date: 2021-03-24)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Chrome Android – Full support
Chrome Android 76 (Release date: 2019-07-30)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – Full support
Opera Android 54 (Release date: 2019-10-18)
footnote Full support
Safari on iOS – Full support
Safari on iOS 14 (Release date: 2020-09-16)
footnote Full support
Samsung Internet – Full support
Samsung Internet 11 (Release date: 2019-12-05)
footnote Full support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – Full support
WebView on iOS 14 (Release date: 2020-09-16)
footnote Full support
Node.js – No support
Node.js
footnote No support
data.text parameter
Chrome – Full support
Chrome 89 (Release date: 2021-03-02)
footnote Full support
Edge – Full support
Edge 81 (Release date: 2020-04-13)
footnote Full support
Firefox – No support
Firefox 96 (Release date: 2022-01-11)
disabled
disabled From version 96 users must explicitly set the dom.webshare.enabled preference to true. To change preferences in Firefox, visit about:config.
Opera – Full support
Opera 75 (Release date: 2021-03-24)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Chrome Android – Full support
Chrome Android 76 (Release date: 2019-07-30)
footnote Full support
Firefox for Android – Full support
Firefox for Android 96 (Release date: 2022-01-11)
footnote Full support
Opera Android – Full support
Opera Android 54 (Release date: 2019-10-18)
footnote Full support
Safari on iOS – Full support
Safari on iOS 14 (Release date: 2020-09-16)
footnote Full support
Samsung Internet – Full support
Samsung Internet 11 (Release date: 2019-12-05)
footnote Full support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – Full support
WebView on iOS 14 (Release date: 2020-09-16)
footnote Full support
Node.js – No support
Node.js
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
See implementation notes.
User must explicitly enable this feature.
Has more compatibility info.

See also