Skip to content

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>
{
"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.

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.

action must be within the manifest scope. If it is not, the browser ignores the share_target entirely.

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');

Intercept the POST in the service worker and pass data to the client:

service-worker.js
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
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
  • action URL is within the manifest scope.
  • For text/URL sharing, query-parameter names match what your page reads.
  • For file sharing, method is "POST", enctype is "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.