A convenient React hook that utilizes input[switch]
introduced in Safari 18.0 to trigger haptic feedback anytime, anywhere in your application.
Try Demo here !!!!! 👈🏻
- Trigger haptic feedback at any time in your React application
- Simple API
npm install use-haptic
yarn add use-haptic
pnpm add use-haptic
bun add use-haptic
git clone https://github.com/posaune0423/use-haptic.git
cd sample
npm install
npm run dev
And then, access the ip address displayed in the console by your iPhone.
> npm run dev
> [email protected] dev
> vite --host
Port 5173 is in use, trying another one...
VITE v5.4.6 ready in 102 ms
➜ Local: http://localhost:5174/
➜ Network: http://192.xxx.xx.xxx:5174/
➜ press h + enter to show help
import { useHaptic } from "use-haptic";
function VibrationButton() {
const { vibe } = useHaptic();
return <button onClick={vibe}>Vibe</button>;
}