Skip to content

tijnjh/ios-haptics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📳 ios-haptics

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

GitHub last commit npm version NPM Downloads npm package minimized gzipped size

demo: ios-haptics demo

📦 installation

npm i ios-haptics

🚀 usage

import { haptic } from 'ios-haptics'

// a single haptic
haptic()

// two rapid haptics
haptic.confirm()

// three rapid haptics
haptic.error()

⚙️ how it works

this uses the <input type="checkbox" switch /> (introduced in safari 17.4), which has haptic feedback when toggled

Important

apple patched the bug this library used for haptic feedback in ios 26.5. you can no longer trigger haptic feedback programmatically by calling .click() on a <label> that is for an <input type="checkbox" switch />. haptic feedback still works when the user directly clicks the checkbox switch themselves, but it can no longer be done programmatically.

every haptic call, it will create one of those in the background, toggle it, then remove it

on devices that support it, navigator.vibrate() is called instead, so it works on android too


feel free to send a pr or open an issue if you have suggestions or find improvements

About

📳 javascript library for haptic feedback inside of safari on ios

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors