ios-haptics exposes three feedback patterns based on context.
// Single tap — general interaction feedbackhaptic()// Double tap — use for successful confirmationshaptic.confirm()// Triple tap — use for errors or destructive actionshaptic.error()
A full TypeScript example with a button that cycles through all three haptic types.
import { haptic } from 'ios-haptics'const button = document.querySelector<HTMLButtonElement>('#haptic-btn')const status = document.querySelector<HTMLSpanElement>('#status')let step = 0button?.addEventListener('click', () => { if (step === 0) { haptic() status!.textContent = 'Single tap' step = 1 } else if (step === 1) { haptic.confirm() status!.textContent = 'Double tap (confirm)' step = 2 } else { haptic.error() status!.textContent = 'Triple tap (error)' step = 0 }})
Haptics only fire on physical iOS and Android devices. They are silently ignored on desktop browsers and simulators, so you can safely call them without any environment checks.