All articles
· 6 min read

Web Share Target: register your PWA as a share destination

Turn your PWA into a first-class share target on Android and ChromeOS — accept text, URLs, images and files from the system share sheet.

TI
The InstantPWA team
Product & engineering

The system share sheet is the highest-intent surface on a mobile OS — someone actively wants to send content somewhere. Adding your PWA to that list is a 10-line manifest change.

Register in the manifest

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

Handle the incoming POST

Your service worker intercepts the POST to /share. Read the FormData, stash it in IndexedDB, then redirect to a UI page:

self.addEventListener('fetch', (event) => {
  const url = new URL(event.request.url);
  if (event.request.method === 'POST' && url.pathname === '/share') {
    event.respondWith((async () => {
      const form = await event.request.formData();
      const payload = {
        title: form.get('title'),
        text: form.get('text'),
        url: form.get('url'),
        image: form.get('image'),
      };
      const cache = await caches.open('share');
      await cache.put('/share-payload', new Response(JSON.stringify(payload)));
      return Response.redirect('/share-view', 303);
    })());
  }
});

Testing

Install the PWA on an Android device, share any content from Chrome or the gallery, and your app appears in the sheet. Chrome DevTools → Application → Manifest validates the share_target JSON before you install.

Common pitfalls

  • Using GET when you need to accept files (they only work over multipart POST).
  • Redirecting to a route that isn’t cached — fails offline.
  • Expecting iOS support — it doesn’t exist. Use the Web Share API for outbound sharing on iOS.

Ship your install prompt in 60 seconds

InstantPWA is one line of code. Free forever for one widget, no card required.

Get started free