A convenient React hook to trigger haptic feedback anywhere in your application
npm install use-hapticA convenient React hook to trigger haptic feedback anywhere in your application
This package utilizes the input[switch] element introduced in
Safari 18.0 to
trigger haptic feedback anytime, anywhere in your React application.
- ✅ Trigger haptic feedback at any time in your React application
- ✅ Support iOS, Android
- ✅ Simple, intuitive API
- ✅ Native TypeScript support by 🦕
- ✅ ESM / CJS compatible
- ✅ jsr / npm compatible
``bash`
npm install use-haptic
`bash`
yarn add use-haptic
`bash`
pnpm install use-haptic
`bash`
bun add use-haptic
`bash`
deno add jsr:@posaune0423/use-haptic
`tsx
import { useHaptic } from "use-haptic";
function HapticButton() {
const { triggerHaptic } = useHaptic();
return ;
}
`
Clone the repository and run the sample app:
`bash`
git clone https://github.com/posaune0423/use-haptic.git
cd sample/deno-vite-react
deno task dev
You can visit the demo page by scanning the QR code displayed in the terminal.
This package uses dnt for npm package
preparation:
`bashBuild the package
deno run -A scripts/build_npm.ts