Install from npm
Install the package
Install ios-haptics using your preferred package manager. Import the library
Import haptic into your module.import { haptic } from 'ios-haptics'
You can also import supportsHaptics if you need to check device support at runtime.import { haptic, supportsHaptics } from 'ios-haptics'
Use it
Call haptic() on any user interaction. Use haptic.confirm() for success states and haptic.error() for errors.// Single tap — general feedback
haptic()
// Double tap — confirmation
haptic.confirm()
// Triple tap — error
haptic.error()
ios-haptics is ESM-only ("type": "module" in package.json). Make sure your project supports ES modules before installing.
CDN usage
You can use ios-haptics directly from a CDN without a build step.
<script type="module">
import { haptic } from 'https://esm.sh/ios-haptics'
document.querySelector('button').addEventListener('click', () => {
haptic()
})
</script>
Alternatively, use unpkg:
<script type="module">
import { haptic } from 'https://unpkg.com/ios-haptics/dist/index.js'
document.querySelector('button').addEventListener('click', () => {
haptic()
})
</script>