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 canShare() method of the Navigator interface returns true if the equivalent call to navigator.share() would succeed.
The method returns false if the data cannot be validated. Reasons the data might be invalid include:
data parameter has been omitted or only contains properties with unknown values. Note that any properties that are not recognized by the user agent are ignored.The Web Share API is gated by the web-share permission policy. The canShare() method will return false if the permission is supported but has not been granted.
canShare() canShare(data)
data OptionalAn object defining the share data to test. Typically, an object with the same properties is passed to navigator.share() if this call returns true.
Properties that are unknown to the user agent are ignored; share data is only assessed on properties understood by the user agent. All properties are optional but at least one known data property must be specified or the method will return false.
Possible values are:
url OptionalA string representing a URL to be shared.
text OptionalA string representing text to be shared.
title OptionalA string representing the title to be shared.
files OptionalAn array of File objects representing files to be shared.
Returns true if the specified data can be shared with Navigator.share(), otherwise false.
The example uses navigator.canShare() to check whether navigator.share() can share the specified data.
The HTML just creates a paragraph in which to display the result of the test.
<p class="result"></p>
let shareData = {
title: "MDN",
text: "Learn web development on MDN!",
url: "https://developer.mozilla.org",
};
const resultPara = document.querySelector(".result");
if (!navigator.canShare) {
resultPara.textContent = "navigator.canShare() not supported.";
} else if (navigator.canShare(shareData)) {
resultPara.textContent =
"navigator.canShare() supported. We can use navigator.share() to send the data.";
} else {
resultPara.textContent = "Specified data cannot be shared.";
}
The box below should state whether navigator.canShare() is supported on this browser, and if so, whether or not we can use navigator.share() to share the specified data:
This method feature tests whether a particular data property is valid and shareable. If used with a single data property it will return true only if that property is valid and can be shared on the platform.
The code below demonstrates verifying that a data property is supported.
// Feature that may not be supported
let testShare = { someNewProperty: "Data to share" };
// Complex data that uses new key
const shareData = {
title: "MDN",
text: "Learn web development on MDN!",
url: "https://developer.mozilla.org",
someNewProperty: "Data to share",
};
// Test that the key is valid and supported before sharing
if (navigator.canShare(testShare)) {
// Use navigator.share() to share 'shareData'
} else {
// Handle case that new data property can't be shared.
}
| Specification |
|---|
| Web Share API> # canshare-data-method> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
canShare |
128 | 9381–93Only supported on Windows. |
96 | 114 | 14 | 75 | 96 | 54 | 14 | 11.0 | No | 14 |
data_files_parameter |
89 | 81 | No | 75 | 14 | 76 | No | 54 | 14 | 11.0 | No | 14 |
data_text_parameter |
89 | 81 | No | 75 | 14 | 76 | No | 54 | 14 | 11.0 | No | 14 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Navigator/canShare