All articles

Technical

Implementing Native-Like Haptic Feedback in Android TWAs

September 30, 2026 · 5 min read

One of the key differences between standard mobile websites and compiled native Android apps is sensory feedback. Native applications use subtle physical vibrations to acknowledge user interactions, such as tapping buttons, adjusting sliders, encountering errors, or completing tasks. For developers packaging web apps using a Trusted Web Activity, replicating this physical feel is essential to matching the native experience demanded by Google Play Store users.

Understanding the Web Vibration API

Since a Trusted Web Activity is powered by modern system browser engines, it possesses full access to standard web hardware integration APIs. To generate tactile physical feedback, developers can use the W3C Web Vibration API. This API exposes device vibration hardware to the web container through a straightforward programming interface.

The API is accessed through the navigator.vibrate method. The method accepts either a single integer, representing a single vibration duration in milliseconds, or an array of integers representing alternating vibration and silence patterns.

To trigger a simple, short vibration, you can call the method with a single value:

navigator.vibrate(100);

For more complex interactions, an array allows you to define distinct rhythms, where odd indexes dictate the duration of active vibration and even indexes dictate silence pauses:

navigator.vibrate([100, 50, 100]);

Standard Haptic Patterns for Android

Using vibration indiscriminately will frustrate users and drain the mobile device battery. To make your Trusted Web Activity feel professional, your haptic feedback should mimic standard Android system behaviour. Avoid long, aggressive hums for simple interactions.

Instead, follow established native patterns for specific user events. The table below outlines standard durations and pauses to use in your PWA code to replicate native Android haptic responses:

User EventVibration Pattern (ms)Feedback Style
Standard button tap[15]Ultra-short, subtle click feel
Long press action[30]Slightly firmer confirmation tick
Task success confirmation[15, 30, 15]Double crisp bounce feedback
Warning alert[40, 50, 40]Moderate double vibration pulse
Critical error or failure[60, 120, 60, 120, 100]Aggressive, noticeable warning pattern

Implementing safe, conditional wrappers

Not every browser engine or hardware device supporting your web application will have a physical vibration motor. Desktop browsers, or browsers on tablets without cellular components, will fail to execute raw vibration commands, or may throw console warnings. To keep your codebase clean and reliable, always wrap your haptic commands in a safety utility check.

A robust wrapper checks if the navigator object and the vibrate method exist before attempting to invoke them. It should also gracefully handle any thrown browser security exceptions:

function triggerHaptic(pattern) { if (typeof navigator !== 'undefined' && navigator.vibrate) { try { navigator.vibrate(pattern); } catch (e) { console.warn('Haptics failed to trigger', e); } } }

You can call this safe helper function throughout your application components. For instance, in an interactive form submission event handler, you can call triggerHaptic([15, 30, 15]) on success, or triggerHaptic([60, 120, 60]) on validation failure.

Navigating Security and System Rules

Modern mobile operating systems implement strict security and accessibility rules regarding device hardware access. For security reasons, the Web Vibration API cannot be triggered automatically on page load or via background scripts. The user must actively interact with the page (via a click, tap, or swipe) before the system browser will allow your TWA to run a physical vibration.

If your application attempts to call navigator.vibrate outside an active, user-initiated event listener, the browser engine will ignore the request. Ensure you always trigger haptics synchronously within tap handlers or user interaction callbacks.

Additionally, respect system-level preferences. Android devices provide global toggles to disable touch feedback and conserve battery. When a user activates Android Battery Saver mode or turns off touch vibration inside their OS Settings menu, Chrome automatically disables navigator.vibrate execution behind the scenes. Your app code does not need to handle this manually, as the browser engine fails silently and safely without interrupting your main application thread.

Polishing the Android App Feel

To deliver a top-tier app on the Google Play Store, look at your UI and find high-value targets for haptic reinforcement. Good targets include toggling switch components, tapping bottom navigation bar icons, triggering biometric login, dragging list elements, or receiving real-time chat messages.

By combining custom CSS overscroll-behavior to control layouts with subtle, hardware-aligned vibration API patterns, your Trusted Web Activity will feel identical to a native Android application, elevating your brand and providing a premium experience to your active mobile users.

Ready to ship your Android app?

Paste your PWA URL, get a signed APK and a Google Play ready AAB in minutes.

Build my app