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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@mhpdev/react-native-haptics

v1.0.1

Published

A high-performance React Native library for iOS haptics and Android vibration effects

Downloads

3,261

Readme

A high-performance React Native library for iOS haptics and Android vibration effects.

Only New Architecture: This library is only compatible with the new architecture. If you're using React Native 0.76 or higher, it is already enabled. However, if your React Native version is between 0.68 and 0.75, you need to enable it first. Click here if you need help enabling the new architecture

Features

  • 🚀  High-performance library built with Turbo Modules for Android and iOS

  • 🎛️  Provides essential methods for triggering native haptic feedback

  • 🤖  Supports a wide range of Android-specific vibration effects

  • 🛠️  Easy to use with simple APIs

  • 🧵  Executes on the UI thread to ensure instant feedback

  • ✅  Fully type-safe and written in TypeScript

Installation

Bare React Native

Install the package using either npm or Yarn:

npm install @mhpdev/react-native-haptics

Or with Yarn:

yarn add @mhpdev/react-native-haptics

For iOS, navigate to the ios directory and install the pods:

cd ios && pod install

Expo

For Expo projects, follow these steps:

  1. Install the package:

    npx expo install @mhpdev/react-native-haptics
  2. Since it is not supported on Expo Go, run:

    npx expo prebuild

Usage

To learn how to use the library, check out the usage section.

Benchmarks (RN Haptics vs Expo Haptics)

The following benchmark results are for 200 time executions (Click here to see the full report repository):

How much faster on iOS (iPhone 14 Pro Max)?

  • Impact Heavy: React Native Haptics is ~2.13x faster than Expo Haptics ($0.779 / 0.365 \approx 2.13$)
  • Notification Success: React Native Haptics is ~3.78x faster than Expo Haptics ($1.378 / 0.365 \approx 3.78$)
  • Selection: React Native Haptics is ~1.72x faster than Expo Haptics ($0.602 / 0.350 \approx 1.72$)

How much faster on Android (Samsung A55)?

  • Impact Heavy: React Native Haptics is ~3.36x faster than Expo Haptics ($9.766 / 2.902 \approx 3.36$)
  • Notification Success: React Native Haptics is ~3.16x faster than Expo Haptics ($10.837 / 3.433 \approx 3.16$)
  • Selection: React Native Haptics is ~3.70x faster than Expo Haptics ($11.236 / 3.037 \approx 3.70$)
  • Android Haptics: Expo Haptics is ~1.72x faster than its React Native Haptics counterpart ($3.238 / 1.879 \approx 1.72$)

Quick Start

import React from 'react';
import Haptics from '@mhpdev/react-native-haptics';
import {SafeAreaView, StyleSheet, Text, TouchableOpacity} from 'react-native';

const App: React.FC = () => {
  const onImpactPress = () => {
    Haptics.impact('heavy');
  };

  return (
    <SafeAreaView style={styles.container}>
      <TouchableOpacity style={styles.button} onPress={onImpactPress}>
        <Text style={styles.buttonText}>Trigger Heavy Impact</Text>
      </TouchableOpacity>
    </SafeAreaView>
  );
};

export default App;

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
  button: {
    padding: 12.5,
    borderRadius: 5,
    backgroundColor: 'skyblue',
  },
  buttonText: {
    fontSize: 22,
    fontWeight: '600',
  },
});

To become more familiar with the usage of the library, check out the example project.

Testing

To mock the package's methods and components using the default mock configuration provided, follow these steps:

  • Create a file named @mhpdev/react-native-haptics.ts inside your __mocks__ directory.

  • Copy the following code into that file:

    jest.mock('@mhpdev/react-native-haptics', () =>
      require('@mhpdev/react-native-haptics/jest'),
    );

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT