Stop paying for native haptic APIs use this web library instead
S

Stop paying for native haptic APIs use this web library instead

Stop paying for native haptic APIs use this web library instead

API
2,660 stars
N/A forks
N/A contributors

README

Project documentation from GitHub

Feel the Web: Adding Haptics Without Native APIs

Let's be honest, haptic feedback on the web has always been a bit of an afterthought. If you wanted to add a tactile buzz or vibration to your web app, you were often stuck with the basic navigator.vibrate() API, which is limited and inconsistent. For anything more advanced, you'd need to look at native SDKs, which means platform-specific code and often, a paid service.

What if you could get rich, expressive haptic effects directly in the browser, for free? That's exactly what the web-haptics library offers. It's a clever JavaScript library that turns the simple vibration API into a powerful tool for creating nuanced tactile experiences.

What It Does

web-haptics is a lightweight JavaScript library that provides a developer-friendly interface for creating complex haptic patterns on supported devices. It sits on top of the Web Vibration API, but instead of just offering a simple "vibrate for 200ms" pattern, it lets you define effects like "sharp click," "soft bump," or a "rumble" using intuitive parameters.

Think of it as a synthesizer for touch feedback. You control the intensity, duration, and sharpness of the vibration to create a wide palette of tactile sensations.

Why It's Cool

The magic here is in the abstraction. The library's author, Lochie, has done the hard work of mapping expressive effect names to the underlying vibration pattern arrays that the browser understands.

  • Expressive & Simple API: Instead of fiddling with arrays like [100, 50, 80], you call haptics.impact('soft') or haptics.notification('success'). It's immediately clear what the intent is.
  • Cross-Platform Foundation: It builds on the web standard (navigator.vibrate), so it works anywhere that API is supported (primarily on Android and in mobile browsers).
  • It's a Polyfill (Kind Of): For platforms that don't support the Web Vibration API at all, it fails gracefully without breaking your code. For platforms that only support simple patterns, it still works.
  • Lightweight & Zero Dependencies: The entire library is tiny, making it a no-brainer to add to any project for a potential UX upgrade.

The clever part isn't reinventing the wheel—it's giving the existing wheel a much better steering system.

How to Try It

Getting started takes about two minutes.

  1. Install it: You can grab it from npm.

    npm inst

Did you like this issue?

Join our weekly newsletter

Related Projects

Love discovering amazing projects?

Help us continue bringing you the best open-source discoveries every week.

Back to Projects
Last updated: Mar 29, 2026