Sharing to other apps

navigator.share()

Limited availability
  • Chrome128
  • Edge93
  • Firefox-
  • Safari12.1

Features it needs

A share library renders a row of buttons, each pointing at one network's own share-intent URL, so the page decides where the content can go. navigator.share() opens the operating system's own share sheet instead, the same one every native app uses, and lets the person pick where it goes.

When this applies

Letting someone share the current page or a piece of content to whatever app they choose.

The native approach

async function share() {
  await navigator.share({
    title: document.title,
    url: location.href,
  });
}

MDN reference

When the dependency is still right

An answer that always says "the platform covers it" is worse than no answer. These are the cases where this one does not hold.

  • You need a button for one specific network, such as a fixed Twitter/X or LinkedIn share link. The OS share sheet lists whatever apps the person has installed, not a chosen set.
  • You support Firefox on desktop. It has never shipped the Web Share API outside Android.
  • You need to share a file the person doesn't already have a URL for. That needs the file-sharing variant of the API, which has narrower browser support again.

Signs it was hand-rolled

No package is involved in any of these, so nothing would match in a package.json. If the code looks like one of them, this rule applies anyway, and the conditions above still decide.

  • a share menu built from hardcoded intent URLs for each network, opened with window.open

Packages this covers