Web Share
Browser Support
Usage
Basic Text and URL Sharing
<div {{ stimulus_controller('@pwa/web-share') }}>
<article>
<h1>Amazing Article Title</h1>
<p>Read this amazing content...</p>
<button {{ stimulus_action('@pwa/web-share', 'share', 'click', {
title: 'Amazing Article Title',
text: 'Check out this amazing article!',
url: 'https://example.com/article/123'
}) }}>
Share Article
</button>
</article>
</div>
<script>
document.addEventListener('pwa--web-share:success', () => {
console.log('Content shared successfully!');
});
document.addEventListener('pwa--web-share:error', (event) => {
console.error('Share failed:', event.detail.error);
});
</script>Sharing Current Page
Sharing Files
Social Media Share with Fallback
Parameters
Actions
share
shareShareable File Types
Targets
Events
pwa--web-share:success
pwa--web-share:successpwa--web-share:error
pwa--web-share:errorBest Practices
Error Handling
Complete Example
Last updated
Was this helpful?