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?

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

1 Comment

I've added more context to the question
0

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

2 Comments

So how does one test this in development do you think?
Android emulator would probably work. Or a tool like ngrok so you can load the dev site on your phone.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.