DeveloperBreeze

Web Development Programming Tutorials, Guides & Best Practices

Explore 42+ expertly crafted web development tutorials, components, and code examples. Stay productive and build faster with proven implementation strategies and design patterns from DeveloperBreeze.

Building Progressive Web Apps (PWAs) with Modern APIs

Tutorial August 05, 2024
json bash

function shareContent() {
  if (navigator.share) {
    navigator.share({
      title: 'My PWA',
      text: 'Check out my Progressive Web App!',
      url: window.location.href
    }).then(() => {
      console.log('Content shared successfully!');
    }).catch(error => {
      console.error('Error sharing content:', error);
    });
  } else {
    console.log('Web Share API is not supported in this browser.');
  }
}

shareContent();

To test your PWA, you need to serve it over HTTPS. You can use a local development server with HTTPS support, such as http-server: