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

tauri-macos-haptics-api

v3.2.0

Published

Modern macOS haptics (Taptic Engine) plugin for Tauri v2 apps with objc2 bindings.

Readme

Tauri macOS Haptics

Modern macOS haptics (Taptic Engine™️) plugin for Tauri v2 apps.

Crates.io npm License: MIT

Modernized and actively maintained by Entro314 Labs. Based on original implementation by ItsEeleeya.

Features

  • 🎯 Type-Safe: Modern objc2 framework with full type safety
  • Latest Tauri: Built for Tauri 2.9+ with all modern features
  • 📱 Complete API: All 3 NSHapticFeedbackPattern types supported
  • 🦀 Modern Rust: Uses Rust 1.77+ with 2021 edition
  • 📝 Well Documented: Comprehensive inline documentation and examples
  • 🔒 Robust Error Handling: Proper error types and handling throughout

Get the plugin

Using the command line from crates.io:

cargo add tauri-macos-haptics

Or add it manually to Cargo.toml:

[target.'cfg(target_os = "macos")'.dependencies]
tauri-macos-haptics = "2.0"

Or get the latest from git:

[target.'cfg(target_os = "macos")'.dependencies]
tauri-macos-haptics = { git = "https://github.com/entro314-labs/tauri-macos-haptics" }

Get the frontend bindings

pnpm add tauri-macos-haptics-api
# or
bun add tauri-macos-haptics-api
# or
npm install tauri-macos-haptics-api
# or
yarn add tauri-macos-haptics-api

Usage

1. Initialize the plugin

This is required to use the plugin from the frontend.

fn main() {
  let mut builder = tauri::Builder::default();

  #[cfg(target_os = "macos")]
  {
    // Initialize the haptics plugin
    builder = builder.plugin(tauri_macos_haptics::init());
  }

  builder
    .run(tauri::generate_context!())
    .expect("error while running tauri application");
}

2. Permissions

Add "tauri-macos-haptics:default" to your permissions. Usually found under src-tauri/capabilities/*.json

Read more about the specific permissions.

3. Perform haptic feedback

From Rust:

use tauri_macos_haptics::haptics::*;

fn provide_feedback() {
  #[cfg(target_os = "macos")]
  {
    // Performs a generic haptic feedback immediately
    HapticFeedbackManager::default_performer()
      .perform(HapticPattern::Generic, None)
      .expect("Failed to perform haptic feedback");

    // Or with specific timing
    HapticFeedbackManager::default_performer()
      .perform(
        HapticPattern::Alignment,
        Some(PerformanceTime::DrawCompleted)
      )
      .expect("Failed to perform haptic feedback");
  }
}

From the frontend (TypeScript):

import {
  isSupported,
  perform,
  HapticFeedbackPattern,
  PerformanceTime,
  HapticError,
} from "tauri-macos-haptics-api";

// Check support first
if (await isSupported()) {
  // Basic usage
  await perform();

  // With specific pattern and timing
  await perform(HapticFeedbackPattern.Alignment, PerformanceTime.Now);

  // With error handling
  try {
    await perform(HapticFeedbackPattern.LevelChange, PerformanceTime.DrawCompleted);
  } catch (error) {
    if (error instanceof HapticError) {
      console.error('Haptic feedback failed:', error.message);
    }
  }
}

Haptic Feedback Patterns

Alignment

Use when the user is dragging an object into alignment with another object:

  • Aligning shapes in a drawing application
  • Snapping to grid positions
  • Reaching minimum/maximum bounds
  • Positioning objects at preferred locations

LevelChange

Use when transitioning between discrete levels or states:

  • Adjusting volume or brightness in steps
  • Switching between preset values
  • Moving through a multi-level accelerator
  • Designed for multilevel accelerator buttons

Generic

General-purpose haptic feedback when no other pattern applies:

  • General confirmation of user actions
  • Default feedback for most interactions

Performance Timing

Default

The system chooses the most appropriate time for feedback based on current conditions.

Now

Provide immediate haptic feedback for instant response to user actions.

DrawCompleted

Provide feedback after the next screen update completes, synchronizing haptic feedback with visual changes.

Important Usage Guidelines

⚠️ Please note that you should trigger feedback ONLY in response to user-initiated actions.

Ideally, visual feedback, such as a highlight or appearance of an alignment guide, should accompany the haptic feedback.

In some cases, the system may override a call to this method. For example, a Force Touch trackpad won't provide haptic feedback if the user isn't touching the trackpad.

Haptic feedback is intended to be provided in response to a user action, such as aligning one object to another. Do not use it to provide feedback for events that are not user initiated. Excessive or unnecessary haptic feedback could be interpreted by the user as a malfunction and could encourage the user to disable haptic feedback entirely.

Learn more about NSHapticFeedbackManager (Apple's documentation)

Example App (Tauri)

The example app lives in the example/ folder and is not published to npm. It’s the fastest way to see the plugin in action with a native-looking UI.

pnpm install
pnpm run-example

System Requirements

  • macOS: 10.11 (OS X El Capitan) or later
  • Hardware: Force Touch trackpad or compatible haptic hardware
  • Rust: 1.77 or later (Rust 2021 edition)
  • Tauri: 2.9 or later

What's New in 2.0

Breaking Changes

  • Migrated from legacy objc/cocoa to modern objc2 framework
  • Updated minimum Rust version to 1.77
  • Renamed internal types (with backward-compatible aliases)

Improvements

  • ✨ Updated to Tauri 2.9 and latest dependencies
  • 🔒 Enhanced type safety with objc2
  • 📚 Comprehensive inline documentation
  • 🎯 Better error handling with HapticError type
  • ⚡ Improved performance and memory safety
  • 🧪 Better TypeScript types and JSDoc comments

Development

Building the plugin

cargo build

Building the TypeScript bindings

pnpm install
pnpm build

Running the example

pnpm run-example

Contributing

Any contributions are welcomed! Feel free to submit issues or pull requests.

License

MIT License - see LICENSE for details.