navigator.share(data) opens the device’s native share UI so the user can send title, text, a url, and/or files (MDN). It returns a Promise that resolves with undefined.
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call navigator.share. Start with this line.
JavaScript
navigator.share(data?)
Call
What it does
navigator.share(data?)
Primary signature.
navigator.share(...)
Call with the arguments your case needs.
Built into the browser. Call share(...) on a Navigator — no import required.
Library declarations
JavaScript
navigator.share(data?)
Parameters
Parameter
Description
data
Optional. Share payload (*at least one known property)
url / text / title
Optional. Strings; empty url means current page (MDN)
files
Optional. File[] — test with canShare first
Return Value
Return Value
Description
*
Promise → undefined
JavaScript Examples
Example 1 — Share a URL (MDN)
Call share from a button click with title, text, and url.
Wrap in try/catch — share rejects on cancel and many failures.
AbortError means the user closed the sheet or no targets (MDN).
Other names (NotAllowedError, TypeError) need a fallback message.
Keep UX calm — cancel is not an app bug.
Compatibility
Browser Support
navigator.share() is part of the Web Share API and is not Baseline. Strong on many mobile browsers and modern Chromium / Safari; desktop support varies. Always feature-detect, require HTTPS, and keep a copy-link fallback.
✓ Limited availability · Not Baseline
Navigator.share()
Native share sheet for title, text, url, and files — Promise<undefined>.
LimitedNot Baseline
Google ChromeSupported (platform-dependent)
Limited
Microsoft EdgeFollow Chromium Web Share support
Limited
Apple SafariStrong on iOS / macOS Safari
Yes
OperaFollow Chromium Web Share support
Limited
Mozilla FirefoxOften limited / flag-gated — feature-detect
Limited
Internet ExplorerNo Web Share support
No
share()Limited
Bottom line: Detect share, validate with canShare when needed, call only from a click, treat AbortError as cancel. See the MDN share() reference.
Frequently Asked Questions
It invokes the device’s native sharing mechanism so the user can send title, text, a URL, and/or files to targets such as Messages, Mail, or social apps (MDN). It returns a Promise that resolves with undefined.
No. MDN does not mark it Deprecated, Experimental, or Non-standard. It is Limited availability (not Baseline) and requires a secure context. Always feature-detect.
The API requires transient activation (a recent user gesture). Scripts cannot open the share sheet at arbitrary times (MDN).
navigator.canShare(data) returns true if share(data) should succeed. Use it especially before sharing files, then call share from the same click handler.
The Promise is typically rejected with AbortError. Treat cancel as a normal outcome, not a hard failure.
Yes. The Web Share API is a secure-context feature (HTTPS or localhost) in supporting browsers (MDN).