Skip to content
Tutorial emka
Menu
  • Home
  • Debian Linux
  • Ubuntu Linux
  • Red Hat Linux
Menu

How to Make Your Website Vibrate with Web Haptics

Posted on March 4, 2026

Ever felt your phone give a tiny “thump” when you click a button in an app? That sensation is called haptic feedback, and it makes digital interactions feel more physical and satisfying. Today, we are going to learn how to bring that same native-app feeling to your mobile websites using a clever tool called Web Haptics.

Adding haptic feedback is a fantastic way to improve User Experience (UX). It provides a tactile confirmation that a user’s action was successful, such as when they submit a form, toggle a switch, or encounter an error. While native apps have had this for a long time, the mobile web has traditionally struggled to keep up—until now. Let’s look at how we can implement this in our web projects.

To get started, we use the web-haptics package, which is available via NPM. This library is quite versatile because it works with popular frameworks like React, Vue, and Svelte, but it can also be used with plain Vanilla JavaScript. For developers using React, the library provides a custom hook called useWebHaptics. When you call this hook, it returns several useful tools: a trigger function to start the vibration, a cancel function to stop it, and an isSupported boolean to check if the user’s browser can actually handle haptics.

The implementation is surprisingly straightforward. Once you have the library installed, you can simply call the trigger() function inside an onClick event handler. For example, if you want a button to vibrate when pressed, you would link the button’s click event directly to that function. The library also includes a debug: true mode. Since you cannot feel vibrations while developing on a laptop, the debug mode plays a subtle sound that mimics the vibration pattern, allowing you to “hear” the haptics while you build.

One of the most powerful features of Web Haptics is the ability to create custom patterns. A vibration isn’t just a simple “on” or “off” switch; you can control three main properties:

  1. Duration: How long the vibration lasts (measured in milliseconds).
  2. Delay: The pause between multiple vibrations.
  3. Intensity: How strong the vibration feels, ranging from a soft “nudge” to a strong “buzz.”

By combining these properties in an array of objects, you can create complex patterns. For instance, a “success” pattern might be two quick, light taps, while an “error” pattern might be one long, heavy vibration. If you find writing these objects tedious, the Web Haptics website offers a visual editor where you can drag and drop vibrations to create the perfect sequence and then copy the resulting code directly into your project.

Now, let’s talk about the technical “magic” happening under the hood. On Android devices, the library uses the standard navigator.vibrate API. This is a built-in browser feature that allows websites to access the phone’s vibration motor. However, there is a major hurdle: Apple’s iOS does not support this API in Safari or Chrome. This means, normally, your iPhone wouldn’t vibrate at all when browsing a website.

The creator of Web Haptics found a brilliant workaround for this limitation. On iOS, specific UI elements like the “switch” or “checkbox” input types have haptic feedback built into the operating system by default. When a user interacts with these elements, the iPhone vibrates automatically. The library takes advantage of this by creating an invisible, tiny checkbox on your page. When you call the trigger() function, the library quickly toggles this hidden checkbox on and off. To the iPhone, it looks like a standard UI interaction, so it triggers the vibration. This “trick” allows web developers to achieve haptic feedback on iOS that feels exactly like a native Apple app.

In conclusion, tactile feedback is a small detail that makes a massive difference in how professional a website feels. By using the web-haptics library, you can bridge the gap between mobile websites and native applications. It is easy to install, highly customizable, and uses clever workarounds to ensure compatibility across both Android and iOS devices. I highly recommend experimenting with different intensities and patterns to see what fits your site’s personality best. Always remember to use haptics sparingly; too much vibration can become annoying, but the right amount can make your website feel truly alive.

Recent Posts

  • Make Linux Kernel More Safe and Hardening with Sysctl Easy Way
  • How to Lockdown Root & Wheel Group in Linux
  • How to Secure Sudo in Linux (Secure Sudo Logging & Timeout)
  • Make Fedora Login Safe with Authselect and Faillock
  • How Measure Linux Security Use OpenSCAP Lynis and Systemd
  • SELinux Make Nginx Break and How to Fix It Easy
  • How See Hidden SELinux Errors When Your Server Is Broken
  • How Fix SELinux Port Denied Error With Sealert Easy Guide
  • Read SELinux AVC Denial Log Simple Guide for Noob
  • How Check and Fix SELinux Block Things in Fedora Linux
  • How Actually SELinux is Work?
  • How to Install Elementary OS 8 Easy and Make It Good
  • How to Install UniFi OS Server on Ubuntu Linux Without Cloud Key
  • Top DNF5 Tips to Make Your Fedora Linux Super Fast
  • Run Local AI on Fedora 44 CPU Without Expensive GPU
  • Google Gemini Live Redesign: Works with more ‘Connected Apps’ on Android
  • A new LILYGO T3S3 ESP32-S3 with LoRA, WiFi & Bluetooth is Released only $16
  • New ESP32 Project: OpenTrafficMap ESP32-C5 C-ITS With 802.11p V2X communication
  • How to Unlock the Hidden Potential of Your Kindle with Amazing Community Plugins
  • How to Use Waze with Android Auto for the Ultimate Driving Experience
  • How to Transform Your GNOME Desktop with GNOME Prism
  • Why Your Google Maps Wear OS Navigation Fails While Using Android Auto
  • Packagist Attacked! How to Detect Hidden Malware Like This?
  • Claude Mythos Keeps Find High-severity Flaws, What You Should You Do?
  • How to Secure Your PHP Applications Against the Recent Laravel-Lang Supply Chain Attack and Credential Stealers
  • Inilah 20 Kampus Swasta Terbaik di Bandung Versi EduRank 2026 untuk Referensi Kuliah Kalian
  • Inilah Syarat dan Cara Daftar Sekolah Kedinasan STPN 2026, Kuota Terbatas!
  • Inilah Cara Daftar PPKB UI 2026 Lengkap dengan Rincian Uang Pangkal Semua Jurusan S1
  • Inilah Aturan Resmi MPLS 2026 dari Kemendikdasmen, Guru dan Sekolah Wajib Catat Pedoman Lengkap Ini!
  • Inilah Cara Daftar Beasiswa S1/D4 Guru Kemendikdasmen 2026, Masa Pendaftaran Diperpanjang!
  • How to Automate Your Entire SEO Strategy Using a Swarm of 100 Free AI Agents Working in Parallel
  • How to create professional presentations easily using NotebookLM’s AI power for school projects and beyond
  • How to Master SEO Automation with Google Gemini 3.1 Flash-Lite in Google AI Studio
  • How to create viral AI video ads and complete brand assets using the Claude and Higgsfield MCP integration
  • How to Transform Your Mac Into a Supercharged AI Assistant with Perplexity Personal Computer
RSS Error: WP HTTP Error: A valid URL was not provided.
©2026 Tutorial emka | Design: Newspaperly WordPress Theme