Feature Detection
WebHaptics provides a staticisSupported property for runtime feature detection:
Usage
Even when
isSupported returns false, you can still instantiate WebHaptics. The library provides visual/audio fallback feedback when debug mode is enabled.Browser Compatibility
Desktop Browsers
| Browser | Support | Notes |
|---|---|---|
| Chrome | ✅ Yes | Full support on Android, limited on desktop |
| Firefox | ✅ Yes | Android only |
| Safari | ❌ No | Not supported (see workarounds) |
| Edge | ✅ Yes | Windows with supported hardware |
| Opera | ✅ Yes | Android only |
Mobile Browsers
| Browser | iOS | Android |
|---|---|---|
| Safari | ❌ Not supported | N/A |
| Chrome | ❌ Not supported | ✅ Full support |
| Firefox | ❌ Not supported | ✅ Full support |
| Samsung Internet | N/A | ✅ Full support |
| Edge | ❌ Not supported | ✅ Full support |
iOS does not support the Vibration API in any browser due to platform restrictions. This includes Chrome, Firefox, and third-party browsers on iOS, which all use WebKit under the hood.
Platform Limitations
iOS Restrictions
Apple does not expose haptic controls to web browsers. Native iOS apps can use the Haptic Feedback API, but web content cannot. Workarounds:- Use the debug mode to provide visual feedback on iOS
- Consider a native wrapper (Capacitor, React Native WebView) with a haptics bridge
- Progressive enhancement: design UI that doesn’t rely solely on haptics
Android Variations
Device-Specific Behavior
Device-Specific Behavior
Android devices vary widely in haptic hardware:
- High-end devices: Linear resonant actuators (LRA) with precise control
- Mid-range devices: Eccentric rotating mass (ERM) motors with lag
- Budget devices: May have weak or no vibration
Security Context Requirements
Permission Model
The Vibration API does not require user permission. It can be triggered immediately after a user gesture (click, touch, keypress).
- Vibration is automatically canceled when the page loses focus
- Browsers may throttle excessive vibration calls
- Some browsers limit maximum duration per call (typically 10 seconds)
Testing Strategies
Development Environment
- Visual feedback: Overlay label flashes on trigger
- Audio feedback: Click sounds at varying pitches
- Works on all browsers, including unsupported ones
User Agent Detection (Not Recommended)
❌ Bad approach:Polyfills and Fallbacks
WebHaptics does not polyfill the Vibration API on unsupported browsers. Instead, it provides:- Feature detection: Check support before triggering
- Debug mode: Visual/audio feedback for testing
- Graceful degradation: Haptics enhance UX but shouldn’t be required
Fallback Strategy Example
Future Compatibility
Will iOS ever support the Vibration API?
Will iOS ever support the Vibration API?
As of 2026, Apple has not indicated plans to support the W3C Vibration API in Safari. However, they have implemented proprietary Taptic Engine APIs for native apps.If you need haptics on iOS:
- Use a native wrapper framework (Capacitor, Cordova)
- Implement a JavaScript bridge to native haptic APIs
- Consider progressive web app (PWA) alternatives