javascript library for haptic feedback inside of safari on ios
please note this only works on ios 17.4 to 26.4, as apple patched it in ios 26.5
demo: ios-haptics demo
npm i ios-hapticsimport { hapticTrigger } from 'ios-haptics'vanilla
const element = document.getElementById('element')
hapticTrigger(element)svelte
<button {@attach hapticTrigger}>click me</button>react
<button ref={hapticTrigger}>click me</button>vue
<button :ref="hapticTrigger">click me</button>this uses the <input type="checkbox" switch /> (introduced in safari 17.4), which has haptic feedback when toggled
hapticTrigger renders one of those on top of your element, so when the user taps it, safari triggers the native haptic feedback
feel free to send a pr or open an issue if you have suggestions or find improvements