navigator.share()
The navigator.share() method invokes the device's native sharing mechanism and passes text, links, files, and other content to share targets. Also known as the Web Share API. It is most useful when native HTML semantics or browser capabilities can replace custom implementation work.
Overview
The navigator.share() method invokes the device's native sharing mechanism and passes text, links, files, and other content to share targets. Also known as the Web Share API. It is most useful when native HTML semantics or browser capabilities can replace custom implementation work.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 128 | 93 | 96 | 14 | 75 | 14 | |
| DOM API | ||||||
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 |
| 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. | 128 | 93 | 71 | 12.1 | 61 | 12.2 |
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 | ||||||
html.elements.iframe.allow.web-share | 86 | 86 | 81 | | 86 | |
http.headers.Permissions-Policy.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
- Requires an experimental browser flag to be enabled
- 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
- Firefox recognizes the `web-share` permissions policy, but this has no effect in versions of Firefox that do not support the `share()` method.
Syntax
await navigator.share({
title: 'Page Title',
text: 'Recommended Articles',
url: 'https://example.com/article'
}); Use cases
Use navigator.share()
Use navigator.share() when standard HTML needs a more specific platform feature, semantic signal, or browser capability.
Handle edge cases
Apply navigator.share() to solve a focused requirement without redesigning the whole page architecture.
Cautions
- Test navigator.share() in your target browsers and input environments before depending on it as a primary behavior.
- Provide a fallback path or acceptable degradation strategy when support is still limited.
Accessibility
- Make sure navigator.share() supports the intended task without making the page harder to perceive, understand, or operate.
Related links
Powered by web-features