keyboard_backspace wifi_off

Web share

This feature is not (yet) supported on your device

The Web Share API invokes the native share mechanism of the device and allows users to share text, URLs or files.

This app is itself also a share target which means content can also be shared to it. When sharing content, this app will be listed as an app to share to.

attach_file
const shareButton = document.querySelector('#share-button'); const title = document.querySelector('#title').value; const text = document.querySelector('#text').value; const url = document.querySelector('#url').value; const fileField = document.querySelector('#file'); const fileName = document.querySelector('#file-name'); shareButton.addEventListener('click', async () => { const files = fileField ? fileField.files : []; const data = {title, text, url}; if(files.length) { data.files = files; } try { await navigator.share(data); } catch(e) { console.log('share error', e); } }); if(fileField) { fileField.addEventListener('change', e => { const {files} = e.target; const {name} = files[0]; if(name) { fileName.innerText = name; } }); }

Documentation

Web Share API on MDN

What PWA Can Do Today A showcase of what is possible with Progressive Web Apps today