4

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?

Werner Raath
  • 1,322
  • 3
  • 16
  • 34

3 Answers3

1

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

abraham
  • 46,583
  • 10
  • 100
  • 152
1

It seems using Chrome Dev Tools to forward the local port to a remote device is the best way to debug on mobile devices and thus test PWA functionality on a device itself.

Werner Raath
  • 1,322
  • 3
  • 16
  • 34
0

http://localhost is considered a secure context … or you could just set up HTTPS in your local development environment.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335