navigator.share()
The share() method of the Navigator interface invokes the native sharing mechanism of the device to share data such as text, URLs, or files. The available share targets depend on the device, but might include the clipboard, contacts and email applications, websites, Bluetooth, etc.
The method resolves a Promise with undefined. On Windows this happens when the share popup is launched, while on Android the promise resolves once the data has successfully been passed to the share target.
The Web Share API is gated by the web-share permission policy. The share() method will throw exceptions if the permission is supported but has not been granted.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 128 | 93 | 71 | 12.1 | 61 | 12.2 | |
| HTML attribute | ||||||
allow (web-share) | 86 | 86 | 81 | | 86 | |
| DOM API | ||||||
| The canShare() method of the Navigator interface returns true if the equivalent call to navigator.share() would succeed. | 128 | 93 | 96 | 14 | 75 | 14 |
canShare (data files parameter) `data.files` parameter | 89 | 81 | | 14 | 76 | 14 |
canShare (data text parameter) `data.text` parameter | 89 | 81 | 96 | 14 | 76 | 14 |
share (data files parameter) `data.files` parameter | 89 | 81 | | 14 | 76 | 14 |
share (data text parameter) `data.text` parameter | 89 | 81 | 71 | 14 | 76 | 14 |
| Other | ||||||
web-share Experimental The HTTP Permissions-Policy header web-share directive controls whether the current document is allowed to use the Navigator.share method of the Web Share API to share text, links, images, and other content to arbitrary destinations of the user's choice. | 88 | 88 | | | 88 | |
- This browser only partially implements this feature
- This feature was removed in a later browser version (128)
- Only supported on ChromeOS and Windows, see bug 40542648 and bug 40729163.
- This browser only partially implements this feature
- This feature was removed in a later browser version (93)
- Only supported on Windows.
- Requires an experimental browser flag to be enabled
- Firefox recognizes the `web-share` permissions policy, but this has no effect in versions of Firefox that do not support the `share()` method.
- This browser only partially implements this feature
- This feature was removed in a later browser version (128)
- Only supported on ChromeOS and Windows, see bug 40542648 and bug 40729163.
- This browser only partially implements this feature
- This feature was removed in a later browser version (93)
- Only supported on Windows.
- Requires an experimental browser flag to be enabled
- Requires an experimental browser flag to be enabled
- Requires an experimental browser flag to be enabled
Syntax
share(data) Use cases
-
Using navigator.share()
The share() method of the Navigator interface invokes the native sharing mechanism of the device to share data such as text, URLs, or files.
Cautions
- Limited browser support. Check compatibility before use.
Implementation notes
- Some APIs require a secure context (HTTPS) or user activation. Check the requirements before use.