Esta página ainda não está disponível em Português, por isso está a ler a versão em inglês.

Web Share and Web Share Target: share to and from your PWA

Use the system share sheet both ways.

Recursos e APIs Iniciante 1 min de leitura Revisado em 27 de nov. de 2026

Sharing from your app: Web Share API

shareButton.addEventListener('click', async () => {
  const data = { title: document.title, text: 'Worth reading', url: location.href };
  if (navigator.share && (!navigator.canShare || navigator.canShare(data))) {
    try { await navigator.share(data); } catch (e) { /* user cancelled */ }
  } else {
    await navigator.clipboard.writeText(location.href); // fallback
  }
});

Share files too: navigator.share({ files: [file], title: 'Photo' }), after checking navigator.canShare({ files: [file] }). It must be called from a user gesture. Supported in Safari (iOS and macOS), Chrome and Edge on Android, Windows and ChromeOS (and newer versions on macOS), Samsung Internet and Firefox for Android.

Receiving shares: Web Share Target

Add a share_target to your manifest, and your installed app appears in the system share sheet:

"share_target": {
  "action": "/share",
  "method": "GET",
  "params": { "title": "title", "text": "text", "url": "url" }
}

The app opens /share?title=...&text=...&url=.... Note that some apps put the link in text rather than url, so check both.

To receive files, use POST with multipart/form-data and handle the request in your service worker:

"share_target": {
  "action": "/share-image", "method": "POST", "enctype": "multipart/form-data",
  "params": { "files": [{ "name": "image", "accept": ["image/*"] }] }
}

Share Target works in Chromium on Android and ChromeOS (and Edge on Windows). It is not supported on iOS.

PWA.live has a share target: install it on Android and share any link to PWA.live to open the PWA checker with that URL.

Compatibilidade de navegadores

Compatibilidade dos navegadores com recursos de PWA
RecursoChrome / Edge desktopChrome AndroidSafari iOS / iPadOSSafari macOSFirefox desktopFirefox AndroidSamsung Internet
Web Share (share from your app) Chrome / Edge desktop: Parcial (Windows, ChromeOS and newer macOS versions) Chrome Android: Sim Safari iOS / iPadOS: Sim Safari macOS: Sim Firefox desktop: Não Firefox Android: Sim Samsung Internet: Sim
Share target (receive shares) Chrome / Edge desktop: Parcial (ChromeOS, and Edge on Windows) Chrome Android: Sim Safari iOS / iPadOS: Não Safari macOS: Não Firefox desktop: Não Firefox Android: Não Samsung Internet: Sim

Ver a tabela completa