Copyright © 2017 the Contributors to the Web Share API Specification, published by the Web Incubator Community Group under the W3C Community Contributor License Agreement (CLA). A human-readable summary is available.
This specification defines an API for sharing text, links and other content to an arbitrary destination of the user's choice.
The available share targets are not specified here; they are provided by the user agent. They could, for example, be apps, websites or contacts.
This specification was published by the Web Incubator Community Group. It is not a W3C Standard nor is it on the W3C Standards Track. Please note that under the W3C Community Contributor License Agreement (CLA) there is a limited opt-out and other conditions apply. Learn more about W3C Community and Business Groups.
This is an early draft of the Web Share spec.
This section is non-normative.
This example shows a basic share operation. In response to a button click, this JavaScript code shares the current page's URL.
: Basic usage
shareButton.addEventListener('click', () => {
navigator.share({title: 'Example Page', url: ''})
.then(console.log('Share successful'));
});
Note that a
of url
''
refers to the current page URL, just as it would in a link. Any other absolute or relative URL can also be used.
In response to this call to navigator.share
, the user agent would display a picker or chooser dialog, allowing the user to select a target to share this title and the page URL to.
This section is non-normative.
Implementations should observe the following security and privacy advice.
Web Share enables data to be sent from websites to native applications. While this ability is not unique to Web Share, it does come with a number of potential security issues that may vary in severity (depending on the underlying platform).
navigator.share
. This information could be used for fingerprinting, as well as leaking details about the user's device.
navigator.share
is rejected. Even distinguishing between the case where no targets are available and user cancellation may reveal information about which apps are installed on the user's device.
navigator.share
, the user MUST be presented with a dialog asking them to select a target application (even if there is only one possible target). This surface serves as a security confirmation, ensuring that websites cannot silently send data to native applications.
navigator.share
is available only in secure
contexts (such as https://
schemes).
navigator.share
from a private browsing mode may leak private data to a third-party application that does not respect the user's privacy setting. User agents should consider presenting additional warnings or disabling the feature entirely when in a private browsing mode.
navigator.share
may be used to exploit buffer overflow or other remote code execution vulnerabilities in native applications that receive shares. There is no general way to guard against this, but implementors should be aware that it is a possibility.
Thanks to the Web Intents team, who laid the groundwork for the web app interoperability use cases. In particular, Paul Kinlan, who did a lot of early advocacy for Web Share.