Tap "Share" in the phone below to open a simulated OS share sheet. Pick a target (success) or tap Cancel (AbortError). This is exactly what navigator.share() triggers.
The Web Share API guide
Both buttons call navigator.share() and the user "cancels". The left catches every rejection as an error (wrong). The right checks err.name === 'AbortError' (correct). Click each.
AbortError — user cancelled / no targets · don't showNotAllowedError — no transient activation / blocked · usually a bugTypeError — invalid data (bad URL, empty) · usually a bugDataError — target failed to receive · offer fallback
Build a ShareData object and validate it. Watch how canShare() on the whole object can return true even when it contains an unknown key — because WebIDL silently ignores unrecognized members.
canShare(data)canShare({[key]: value})Draw something below, then share it. We use canvas.toBlob() → new File() → canShare({files}) → share(), with a download fallback.
A robust share button tries three tiers in order. Toggle which capabilities are "available" to see which tier handles the share.