> ## Documentation Index
> Fetch the complete documentation index at: https://docs.median.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Haptics

> Trigger haptic feedback effects and respond to the shake gesture on iOS and Android with the Haptics plugin and the JavaScript Bridge.

The Haptics plugin lets you trigger haptic vibration effects used to provide feedback to end users based on various events and actions within your app. Support is provided for six different haptic effects that have been specifically designed to be comparable across iOS and Android devices.

The plugin also provides support for the "shake" gesture such that a JavaScript callback is invoked when the user shakes their device.

> [!TIP]
>
> **Test  with our demo page**
>
> We host a ready-made demo page at
>
> that calls the  features through the Median JavaScript Bridge.
> Load it inside your Median app during development, either by setting it
> as your app's website URL in App Studio or by navigating to it from your
> own site, and use it to confirm  works on a real device before
> you add it to your own pages.
>
> The demo page only works inside a Median app with  enabled.
> Opened in a regular mobile or desktop browser, the native features
> won't respond. Remember to switch your app back to your own URL before
> release.

## Why use haptics

* **Cross-platform consistency**: Six haptic styles have been specifically designed to be comparable across iOS and Android devices, so your feedback patterns work uniformly regardless of platform.
* **Rich haptic vocabulary**: Choose from impact and notification styles to match the intensity and meaning of each interaction in your app.
* **Android-exclusive styles**: Three additional Android-only styles (`tick`, `click`, `double_click`) give you extra expressiveness on Android devices.
* **Shake gesture support**: Respond to physical device shake events with a JavaScript callback, enabling shake-to-action patterns without additional native code.

## Prerequisites

* [ ] A Median app with the JavaScript Bridge enabled
* [ ] The Haptics plugin enabled under **Native Plugins** in Median App Studio
* [ ] A physical iOS or Android device for testing (haptics do not deliver meaningful feedback in a virtual simulator environment)

## Implementation guide

### App setup

1. **Navigate to Native Plugins**: In App Studio, go to **Native Plugins**.
2. **Enable Haptics**: Toggle the Haptics plugin to enabled status. The plugin can also be trialed.

![Haptics plugin in the Native Plugins list in App Studio](https://mintcdn.com/median-co/dZQPJ_0wlG7WNBTy/images/docs/4af20a67444dbf148ebc34d28780ed05374e33e2160f7d34287a4f1c52ed40a1-Screenshot_2026-06-29_at_16.06.30.png?fit=max\&auto=format\&n=dZQPJ_0wlG7WNBTy\&q=85\&s=b1dc2f4ed1844fde3b93529dcdf39b2f)

Haptics plugin enablement

### JavaScript Bridge implementation

#### Trigger haptic vibration event

Triggers a haptic vibration effect on the user's device. Pass a `style` string to specify which effect to fire.

Median JavaScript Bridge

```javascript JavaScript theme={null}
median.haptics.trigger({ style: "impactLight" });
```

`style` is a string parameter that can be any of the following options:

**iOS and Android**

* `impactLight`
* `impactMedium`
* `impactHeavy`
* `notificationSuccess`
* `notificationWarning`
* `notificationError`

**Android only**

* `tick`
* `click`
* `double_click`

#### Respond to shake gesture

Add the `median_device_shake()` JavaScript function to all pages that should provide a response to the shake gesture. You can also insert this function using the [custom JavaScript](https://docs.median.co/docs/custom-js.md) feature.

For example:

Median JavaScript Bridge

```javascript JavaScript theme={null}
function median_device_shake(){
 document.querySelector('.sideNavigation').style.visibility = "visible";
};
```

## Testing checklist

Use this checklist to ensure Haptics is working correctly in your app:

* [ ] Each `style` value triggers a distinct haptic effect on a physical device
* [ ] `median_device_shake` is invoked when the device is shaken
* [ ] Haptic feedback intensity matches the action's visual and semantic weight
* [ ] Plugin does not interfere with app navigation or core web flows
* [ ] All haptic behavior is verified on a physical device, not a simulator

## Frequently asked questions

> [accordion] No haptic feedback in the simulator?
>
> This is expected behavior. Haptics will not deliver meaningful feedback in a virtual simulator environment. Test on a physical iOS or Android device to verify haptic behavior.

> [accordion] Android-only styles not firing?
>
> The `tick`, `click`, and `double_click` styles are supported on Android only. If you are testing on an iOS device, these styles will have no effect. Verify you are testing on a physical Android device.

> [accordion] Shake gesture callback not responding?
>
> Confirm that the `median_device_shake()` function is defined on the current page. You can add it globally using the [custom JavaScript](https://docs.median.co/docs/custom-js.md) feature. Ensure the function name matches exactly: `median_device_shake`.


## Related topics

- [Add haptic feedback to your Lovable app](https://docs.median.co/docs/add-haptic-feedback-to-your-lovable-app.md)
- [Adding haptic feedback to your Base44 app](https://docs.median.co/docs/adding-haptic-feedback-to-your-base44-app.md)
- [Add haptic feedback to your Replit app](https://docs.median.co/docs/add-haptic-feedback-to-your-replit-app.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.