PWA: Getting Web Share API to work in development

Viewed 1613

Since Google Chrome and Firefox does not support Web Share yet, I need some alternative way to test this in development.

Sharing is achieved via this example:

if (navigator.share) {
  navigator.share({
    title: 'web.dev',
    text: 'Check out web.dev.',
    url: 'https://web.dev/',
  })
    .then(() => console.log('Successful share'))
    .catch((error) => console.log('Error sharing', error));
} else {
  console.warn('Cannot share in this browser')
}

Which will log for any unsupported browser:

Cannot share in this browser

Any ideas of how to get this to work for development?

3 Answers

Most desktop browsers do not support the Web Share API. Currently Chrome is one that does not.

Related