npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

capacitor-rich-haptics

v0.10.4

Published

Capacitor plugin for rich, native-quality haptics. iOS Core Haptics with custom intensity, sharpness, AHAP playback, live parameter modulation, preloading, synchronized audio, 60 built-in patterns, pattern transformations, BPM sync, SVG visualizer, React/

Readme

capacitor-rich-haptics

CI npm coverage license

Native-quality haptic feedback for Capacitor — the same nuanced taps and textures you feel in first-party iOS apps, with a real Core Haptics engine, live parameter modulation, AHAP playback, native preloading, and a built-in pattern library.

The official @capacitor/haptics plugin only exposes the legacy UIImpactFeedbackGenerator API (Light / Medium / Heavy). This plugin gives you the full Core Haptics engine on iOS — custom intensity, sharpness, continuous vibrations, AHAP files, and live parameter modulation — and maps the same API to Android's modern VibrationEffect.Composition primitives.

Highlights

  • Core Haptics on iOS + VibrationEffect.Composition on Android behind one API
  • AHAP playback from bundle file, runtime JSON, or the fluent ahap() builder
  • Live parameter modulation — change intensity/sharpness during a continuous haptic
  • 60 built-in patterns across 12 categories — tree-shakeable per pattern (~1 KB each)
  • 29 cross-platform UX presetssoftTap, success, error, mediumImpact, etc.
  • React + Vue adaptersuseHaptics, useHapticDrag, <HapticButton>
  • App-wide kill switch + global intensity scale for settings UIs
  • Reduce Motion respected automatically
  • CLI for validate / list / export / render / migrate

For recipes, transforms, sequence builder, recorder, diagnostics, BPM loops, SVG visualizer, testing utilities, AI-agent guide, and contributing — see the full guide in AGENT.md (auto-mirrored as CLAUDE.md).

Install

npm install capacitor-rich-haptics
npx cap sync

Requires Capacitor 6+. iOS 14+. Android API 23+.

Quick start

import { RichHaptics, ahap, patterns } from 'capacitor-rich-haptics';

// 1. Detect support
const { supported, engine, userEnabled } = await RichHaptics.isSupported();
// → engine: 'core-haptics' | 'composition' | 'basic' | 'web' | 'none'

// 2. Cross-platform preset (start here)
await RichHaptics.preset({ name: 'sharpClick' });

// 3. Custom haptic
await RichHaptics.play({ intensity: 0.8, sharpness: 0.4 });

// 4. Built-in pattern
await RichHaptics.playPattern({ pattern: patterns.heartbeat });

// 5. Build your own
const myPattern = ahap()
  .tap({ intensity: 1.0, sharpness: 0.9 })
  .wait(0.2)
  .continuous({ duration: 0.5, intensity: 0.6, sharpness: 0.2 })
  .rampIntensity({ from: 0.6, to: 0.0, duration: 0.5 })
  .build();
await RichHaptics.playPattern({ pattern: myPattern });

Compatibility

| Capacitor | Status | |---|---| | 8.x / 7.x | ✅ Tested, recommended | | 6.x | ✅ Supported (min peer) | | 5.x and below | ❌ Use @capacitor/haptics instead |

| Platform | Min version | Engine on supported devices | |---|---|---| | iOS | 14.0 | CHHapticEngine on A13+ chips (iPhone 11 / iPad Pro 2020+). Older devices get a no-op. | | Android | API 23 (Android 6) | VibrationEffect.Composition on API 31+ • createOneShot on API 26+ • vibrate(ms) on older | | Web | Modern browsers | navigator.vibrate on mobile • Web Audio click on desktop |

| Framework adapter | Min | |---|---| | React | 17+ | | Vue | 3.0+ | | Angular / Solid / Svelte / vanilla | works via the core RichHaptics plugin (no adapter needed) |

Live parameter modulation

The Core Haptics feature that motivated this plugin — modulate intensity and sharpness mid-playback. Drag gestures, sliders, loaders, breathing animations:

const { id } = await RichHaptics.startContinuous({ intensity: 0.3, sharpness: 0.5 });

element.addEventListener('pointermove', (e) => {
  RichHaptics.updateParameters({
    id,
    intensity: e.clientY / window.innerHeight,
    sharpness: e.clientX / window.innerWidth,
  });
});

element.addEventListener('pointerup', () => RichHaptics.stopPlayer({ id }));

On Android the plugin simulates this by re-triggering Composition primitives at ~30 Hz — not as smooth as iOS, but works. React/Vue users get a more ergonomic version via useHapticDrag — see the full guide.

Migrating from @capacitor/haptics

Run the codemod:

npx capacitor-rich-haptics migrate ./src --write
npm uninstall @capacitor/haptics
npm install capacitor-rich-haptics
npx cap sync

It rewrites Haptics.impact(...), Haptics.notification(...), Haptics.selectionStart/Changed/End, and Haptics.vibrate(...) to their RichHaptics equivalents. The full mapping table is in AGENT.md.

Why this exists

@capacitor/haptics wraps UIImpactFeedbackGenerator, which caps you at three preset weights and zero composability. Apps with custom UX — typing taps, slider scrubbing, milestone celebrations, breathing exercises, drag gestures — need fine-grained control over intensity & sharpness, live modulation during playback, and composed AHAP patterns. That requires CHHapticEngine on iOS and VibrationEffect.Composition on Android — both wrapped by this plugin behind one API.

Full documentation

The deep guide lives in AGENT.md (auto-mirrored to CLAUDE.md so Claude Code, Cursor, Aider, and other AI tooling all read the same content):

  • Decision tree — "user wants X → use Y" — for every preset and pattern
  • All 29 presets and 60 patterns with iOS/Android tuning tables
  • Recipes for React, Vue, and vanilla JS
  • Pattern transformations, sequence builder, recorder, diagnostics
  • BPM loops, SVG visualizer, testing utilities
  • Engine reset events, accessibility, platform behaviour matrix
  • Synchronized audio (iOS), CLI, live playground
  • "What NOT to do" — common pitfalls
  • Contributing guide — adding presets, patterns, transforms

License

MIT © Sergey Faraday