Haptic feedback for the web: vibration on Android, native ticks on iPhone.
npm i browser-hapticAttach feedback to an element once. On iPhone, attach() covers it with an invisible native switch, so the user's own tap plays the tick. Since iOS 26.5 this is the only way to get haptics on iPhone. On Android it vibrates with the preset.
import { useEffect, useRef } from "react";
import Haptic from "browser-haptic";
const SaveButton = () => {
const ref = useRef<HTMLButtonElement>(null);
useEffect(() => Haptic.attach(ref.current!, "success"), []);
return <button ref={ref} onClick={save}>Save</button>;
};