Skip to content

osaxyz/vue-haptics

 
 

Repository files navigation

vue-haptics

vue-haptics

A convenient Vue composable to trigger haptic feedback anywhere in your application

Overview

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

Features

  • Trigger haptic feedback at any time in your Vue application
  • Support iOS, Android
  • Simple, intuitive API
  • Native TypeScript support
  • ESM / CJS compatible

Installation

npm install vue-haptics
yarn add vue-haptics
pnpm add vue-haptics
bun add vue-haptics

Usage

<script setup lang="ts">
import { useHaptic } from "vue-haptics";

const { triggerHaptic } = useHaptic();
</script>

<template>
  <button @click="triggerHaptic">Feel Haptic</button>
</template>

Quick Start

Clone the repository and run the sample app:

git clone https://github.com/osaxyz/vue-haptics.git
cd sample/vite-vue
npm install
npm run dev

You can visit the demo page by scanning the QR code displayed in the terminal.

Development

# Install dependencies
npm install

# Run tests
npm test

# Build
npm run build

Publishing to npm

npm run build
npm publish --access public

License

MIT

About

A convenient Vue composable to trigger haptic feedback anywhere in your application.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • TypeScript 95.7%
  • JavaScript 4.3%