An interactive dev tool for testing Web Share API implementations with realistic platform mockups and live interception capabilities.
- Platform Mockups: Realistic share dialogs for iOS, Android, macOS, Windows using devices.css
- Share Target Apps: Messages, Mail, Twitter, WhatsApp with authentic UI styling
- Interactive Flow: Click share targets in sender view to jump to receiver view
- Real-time Updates: Form changes instantly reflect across all mockups
- WebSocket Integration: Real-time connection to testing server
- Automatic Capture: Intercepts
navigator.share()calls from any page with shim script - Live Updates: Testing interface updates immediately when shares are intercepted
- Dev-focused: By default, only sends to tester (no OS share dialog)
- Runtime Configuration: Toggle original share functionality as needed
- Glassmorphism UI: Beautiful backdrop-filter effects and gradients
- Responsive Design: Works on desktop, tablet, and mobile
- Dark/Light Themes: Automatic theme adaptation
- Smooth Animations: Polished interactions and transitions
npm install web-share-tester --save-devPerfect for exploring Web Share API behavior and designing share flows:
npx web-share-tester
# Opens testing interface at http://localhost:3001Test real Web Share API calls from your existing development app:
# Terminal 1: Start your existing dev server
npm run dev # Your app (e.g., React, Vue, etc.) on localhost:3000
# Terminal 2: Start Web Share Tester
npx web-share-tester # Tester on localhost:3001Then manually add the shim script to your app's HTML:
<!-- Add this script tag to your development app -->
<script src="http://localhost:3001/web-share-tester-shim.js"></script>Now your app's navigator.share() calls will appear in the tester interface!
Perfect for designing and testing share workflows:
- Open http://localhost:3001
- Select a platform (iOS, Android, macOS, Windows)
- Enter share data (title, text, URL)
- View realistic platform share dialogs
- Click share target apps to see receiver mockups
- Switch between sender and receiver views
Important: Interception requires manual integration - it's not automatic!
-
Start both servers:
# Terminal 1: Your existing development server cd my-app npm run dev # Running on localhost:3000 # Terminal 2: Web Share Tester npx web-share-tester # Running on localhost:3001
-
Add the shim script to your app:
<!DOCTYPE html> <html> <head> <!-- Add this script BEFORE your app's JavaScript --> <script src="http://localhost:3001/web-share-tester-shim.js"></script> </head> <body> <button onclick="shareContent()">Share</button> <script> async function shareContent() { try { // This call will now be intercepted and displayed in the tester! await navigator.share({ title: 'My App', text: 'Check out this awesome content!', url: 'https://myapp.com/content' }); } catch (error) { console.error('Share failed:', error); } } </script> </body> </html>
-
Watch the magic happen:
- Click "Share" in your app (localhost:3000)
- See the data appear in the tester interface (localhost:3001)
- No OS share dialog appears by default (dev-focused testing)
The shim script replaces navigator.share() in your browser with a version that:
- โ Sends share data to the Web Share Tester via HTTP
- โ Validates data according to Web Share API spec
- โ Optionally triggers the original OS share dialog (configurable)
- โ Works as a polyfill if Web Share API isn't supported
Control the interceptor behavior from your browser console:
// Enable/disable original OS share dialog
window.webShareTester.enableOriginalShare(true) // Both tester + OS
window.webShareTester.enableOriginalShare(false) // Only tester (default)
// Toggle debug logging
window.webShareTester.enableDebug(true)
// View current configuration
window.webShareTester.getConfig()
// Test share with current settings
window.webShareTester.testShare({
title: 'Test',
text: 'Testing the share functionality...'
})| Platform | Share Dialog | Receiver Apps |
|---|---|---|
| iOS | Native iOS share sheet with blur effects | Messages, Mail, Twitter, WhatsApp |
| Android | Material Design share bottom sheet | Native Android app styling |
| macOS | macOS modal dialog with window controls | Desktop app interfaces |
| Windows | Windows share dialog with system styling | Windows app mockups |
Web Share API Tester uses a client-side interception approach rather than network-level routing:
graph LR
A[Your App] --> B[Shim Script]
B --> C[Web Share Tester Server]
B --> D[Original Share Dialog]
C --> E[Testing Interface]
- Script Loading: The shim script loads and runs in your app's browser context
- API Replacement:
navigator.share()gets replaced with an intercepting version - Data Capture: When your app calls
navigator.share(), the data is captured - Dual Action: Data is sent to the tester AND optionally to the OS (configurable)
- Live Updates: The tester interface updates in real-time via WebSocket
โ No automatic interception of all Web Share API calls on your system
โ No network-level routing or traffic interception
โ No modification of your development server
โ No system-wide hooks or background processes
โ
Manual integration via a simple script tag
โ
Client-side replacement of the Web Share API function
โ
Configurable behavior (tester-only vs. tester + OS share)
โ
Development-focused experience with detailed logging
GET /- Main testing interfaceGET /test- Simple test applicationGET /web-share-tester-shim.js- Client interceptor scriptPOST /api/share- Receive intercepted share dataGET /api/health- Server health checkWebSocket /- Real-time communication
const CONFIG = {
serverPort: 3001, // Server port (auto-detected)
enableOriginalShare: false, // Send to OS share dialog
debug: true // Console logging
}npm run dev # Start Vite dev server for interface development
npm run build # Build the testing interface
npm run start # Build and start production server
npm run server # Start server (requires pre-built dist/)
npm run test:integration # Run both dev and server concurrentlyโโโ src/ # Preact testing interface
โ โโโ app.jsx # Main application component
โ โโโ app.css # Glassmorphism styling
โ โโโ components/ # Platform mockup components
โโโ server/ # Express server with WebSocket support
โ โโโ index.js # Main server with API endpoints
โ โโโ client-shim.js # Web Share API interceptor script
โโโ plugins/ # Build tool integrations
โ โโโ vite-plugin-web-share-tester.js
โโโ test/ # Test applications
โ โโโ test-app.html # Simple test page
โโโ dist/ # Built interface (created by npm run build)
// Set custom port via environment variable
PORT=8080 npx web-share-tester
// Or programmatically
const { WebShareTesterServer } = require('web-share-tester/server');
const server = new WebShareTesterServer({ port: 8080 });
await server.start();// vite.config.js example
import { defineConfig } from 'vite'
import webShareTester from 'web-share-tester/plugins/vite-plugin-web-share-tester'
export default defineConfig({
plugins: [
webShareTester({
port: 3001,
autoStart: true
})
]
})โ "Why aren't my shares being intercepted?"
- Check: Did you add the shim script to your app's HTML?
<script src="http://localhost:3001/web-share-tester-shim.js"></script>
- Check: Is the shim script loading BEFORE your share code?
- Check: Are both servers running (your app + Web Share Tester)?
- Remember: Interception is NOT automatic - it requires manual integration!
โ "I ran npx web-share-tester but my app's shares aren't showing up"
- This is expected! The tester doesn't automatically capture all shares on your system
- You need to manually add the shim script to your development app
- See the "Live Testing with Your App" section above
WebSocket connection failed:
- Check if port 3001 is available
- Verify firewall settings
- Try a different port using
PORT=8080 npx web-share-tester
Share interception not working:
- Ensure the shim script loads before your share code
- Check browser console for any errors (look for Web Share Tester logs)
- Verify the testing server is running
- Try the test page at http://localhost:3001/test to verify the server works
Platform mockups not displaying:
- Ensure you have a stable internet connection (devices.css loads externally)
- Check browser developer tools for CSS loading errors
- Try refreshing the page
โ "Can I use this in production?"
- No! This is a development tool only
- Never include the shim script in production builds
- Use conditional loading for development only:
<script> if (location.hostname === 'localhost' || location.hostname === '127.0.0.1') { document.write('<script src="http://localhost:3001/web-share-tester-shim.js"><\/script>'); } </script>
We welcome contributions! Please see our Contributing Guide for details.
- Fork and clone the repository
- Install dependencies:
npm install - Start development server:
npm run dev - Start testing server:
npm run server(in another terminal) - Make your changes and test thoroughly
- Submit a pull request
- File Sharing Support: Handle
filesproperty of Web Share API - File Type Validation: Comprehensive MIME type checking
- File Previews: Thumbnail generation for images, type icons for others
- Enhanced Mockups: File attachment UIs for all platforms
- Custom Themes: User-defined color schemes
- Export Functionality: Save test scenarios and share data
- Plugin System: Extensible architecture for custom platforms
- Performance Monitoring: Share API performance metrics
This project is licensed under the MIT License - see the LICENSE file for details.
- devices.css for beautiful device mockups
- Preact for the lightweight React alternative
- Vite for the lightning-fast build tool
- The Web Share API specification and community
Made with โค๏ธ for the web development community
If this tool helped you, please consider starring the repository and sharing it with others!