# Haptic feedback plugin

Source: https://saastostore.com/plugins/haptics

Haptic feedback is the short vibration that confirms a tap, a success or an error. It's a small detail, but it's one of the things that make an app feel native rather than like a website. What the person feels depends on their phone and its settings.

## When to use it

- A light tap on the main buttons
- A success feedback when a form is sent
- An error feedback when something fails
- A soft tick when moving through a picker

Keep it for moments that matter. A vibration on every tap quickly gets annoying.

## Set it up

1. **Add the plugin** In your project's plugin library, add Haptic feedback, then launch a new build.
2. **Call it from your site** Call each method optionally: it doesn't exist in a normal browser.

## JavaScript API

```js
const haptics = window.saastostore?.haptics;
await haptics?.impact({ style: "medium" });       // light | medium | heavy
await haptics?.notification({ type: "success" }); // success | warning | error
await haptics?.selection();                       // a light tick
await haptics?.vibrate({ duration: 200 });        // ms, 1 to 1000
// → { ok: true }
// → { ok: false, error: "invalid_argument" }     e.g. duration: 5000
// → { ok: false, error: "not_available" }        Android: the device plays nothing
```

| Method | Argument | Default |
| --- | --- | --- |
| `impact` | `style`: `light`, `medium`, `heavy` | `medium` |
| `notification` | `type`: `success`, `warning`, `error` | `success` |
| `selection` | None | None |
| `vibrate` | `duration`: 1 to 1000 ms | 300 |

iOS can't set a duration, so `vibrate` plays a strong impact. On Android, calls answer `not_available` when the device plays nothing, as on most tablets and TVs. iOS answers `ok: true` in that case.

## Prompt for AI builders

**Prompt for Lovable, Bolt or Base44**

```text
My website also runs inside a mobile app. Inside the app, window.saastostore?.haptics gives access to haptic feedback. In a normal browser it doesn't exist, and nothing must change.

Call it optionally: window.saastostore?.haptics?.impact(...). Its promise never rejects.

Call haptics.impact({ style: "light" }) when a main button is tapped, and haptics.notification({ type: "success" }) or ({ type: "error" }) after a form succeeds or fails.
```

Then test on a real phone. Emulators don't vibrate.

## Frequently asked questions

### Does it need a permission prompt?

No. Android declares the vibrate permission in the app, and no prompt is shown.

### Why don't I feel anything?

The phone may have haptic feedback turned off, or no vibrator. On Android, the call then answers not_available.

### Does it work in the Android Build (Web)?

No. That build opens your site in Chrome, with no window.saastostore. Use the Android Build (Native).
