use-haptic
TypeScript icon, indicating that this package has built-in type declarations

1.1.11 • Public • Published

use-haptic 📳

A convenient React hook to trigger haptic feedback anywhere in your application

CI npm package downloads

✨ Overview

This package utilizes the input[switch] element introduced in Safari 18.0 to trigger haptic feedback anytime, anywhere in your React application.

🚀 Features

  • ✅ 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

📦 Installation

npm install use-haptic
yarn add use-haptic
pnpm install use-haptic
bun add use-haptic
deno add jsr:@posaune0423/use-haptic

🔧 Usage

import { useHaptic } from "use-haptic";

function HapticButton() {
  const { triggerHaptic } = useHaptic();
  return <button onClick={triggerHaptic}>Feel Haptic</button>;
}

🏃‍♂️ Quick Start

Clone the repository and run the sample app:

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.

🧰 Development

Publishing to npm

This package uses dnt for npm package preparation:

# Build the package
deno run -A scripts/build_npm.ts <version>

# Publish to npm
cd npm
npm publish

📄 License

MIT

Package Sidebar

Install

npm i use-haptic

Weekly Downloads

78

Version

1.1.11

License

MIT

Unpacked Size

18.9 kB

Total Files

23

Last publish

Collaborators

  • posaune0423