Manifest share_target
In one line: share_target registers your installed PWA in the OS native share sheet so other apps can share URLs, text, titles, and files directly into your app. On Android and Windows the system delivers the shared data as a GET or POST request to a URL you specify — your service worker or page handler then processes it.
Syntax — sharing text, URLs, and titles (GET)
Section titled “Syntax — sharing text, URLs, and titles (GET)”{ "share_target": { "action": "/app/share-handler", "method": "GET", "params": { "title": "title", "text": "text", "url": "url" } }}When a user shares content to your app, the browser navigates to:
/app/share-handler?title=<shared-title>&text=<shared-text>&url=<shared-url>Syntax — sharing files (POST)
Section titled “Syntax — sharing files (POST)”{ "share_target": { "action": "/app/share-handler", "method": "POST", "enctype": "multipart/form-data", "params": { "title": "title", "text": "text", "url": "url", "files": [ { "name": "media", "accept": ["image/*", "video/mp4"] } ] } }}File sharing requires "method": "POST" and "enctype": "multipart/form-data". The files array lists accepted MIME types.
Properties
Section titled “Properties”| Property | Required | Description |
|---|---|---|
action |
Yes | In-scope URL that receives the share payload. Must be within scope. |
method |
No | "GET" (default) or "POST". Use POST for file sharing. |
enctype |
No | Encoding for POST bodies. Must be "multipart/form-data" when files is set. |
params.title |
No | Query-parameter name for the shared title string. |
params.text |
No | Query-parameter name for the shared text string. |
params.url |
No | Query-parameter name for the shared URL. |
params.files |
No | Array of {name, accept} objects defining accepted file types. |
Scope constraint
Section titled “Scope constraint”action must be within the manifest scope. If it is not, the browser ignores the share_target entirely.
Handling share payloads
Section titled “Handling share payloads”GET handler (text/URL)
Section titled “GET handler (text/URL)”Read query parameters from the URL on page load:
const params = new URLSearchParams(location.search);const sharedUrl = params.get('url');const sharedText = params.get('text');POST handler (files)
Section titled “POST handler (files)”Intercept the POST in the service worker and pass data to the client:
self.addEventListener('fetch', (event) => { if (event.request.method === 'POST' && event.request.url.includes('/share-handler')) { event.respondWith((async () => { const data = await event.request.formData(); const files = data.getAll('media'); // Cache or forward files, then redirect to app return Response.redirect('/app/editor', 303); })()); }});Platform support
Section titled “Platform support”| Platform | Support |
|---|---|
| Android (Chrome 76+) | GET and POST (including files) |
| Windows (Edge 79+) | GET; POST with limited file support |
| iOS (Safari) | Not supported |
| macOS (Chrome/Edge) | Not supported |
Practical checklist
Section titled “Practical checklist”-
actionURL is within the manifestscope. - For text/URL sharing, query-parameter names match what your page reads.
- For file sharing,
methodis"POST",enctypeis"multipart/form-data", and accepted MIME types are listed. - The service worker handles POST requests and redirects after processing.
- You have tested sharing from another app (e.g., the system browser) to your PWA on Android.
- The handler degrades gracefully when query parameters are missing or the file list is empty.