Web Share API

await navigator.share({
  title: 'the title to be shared (may be ignored)'
  url: 'a url string to be shared',
  text: 'some text to be shared',
  files: [file_objects_to_be_shared]
})

The Web Share API opens and uses the user’s operating system’s native sharing menu to share content to user-selected targets.

 

Also available is navigator.canShare(), which returns whether the client is supported (boolean); see browser compatability.

The web-share permission and “transient activation” (i.e. a user-triggered event) is required for security purposes. As of writing, the dom.webshare.enabled feature flag must be manually enabled in Firefox, and it does not support file sharing altogether.