Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/web-haptics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Show or hide the haptic feedback toggle switch.

### `WebHaptics.isSupported`

Static boolean — `true` if the device supports the Vibration API.
Static boolean — `true` if the device supports haptics (touch devices such as iOS and Android).

## License

Expand Down
13 changes: 9 additions & 4 deletions packages/web-haptics/src/lib/web-haptics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,14 @@ export class WebHaptics {
this.showSwitch = options?.showSwitch ?? false;
}

static readonly isSupported: boolean =
private static readonly supportsVibrationAPI: boolean =
typeof navigator !== "undefined" && typeof navigator.vibrate === "function";

static readonly isSupported: boolean =
typeof navigator !== "undefined" &&
(typeof navigator.vibrate === "function" ||
navigator.maxTouchPoints > 0);

@lochie lochie Mar 15, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after doing some research i dont think maxTouchPoints actually is accurate for when haptics are truly supported? i believe this would be true on touch enabled laptops 🤔

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot. I did add some updates to ensure to validate the device is actually a mobile device.
iPads are not supported like iPhones in Web haptics, so made sure to not capture them as well.

Let me know what you think


async trigger(
input: HapticInput = [{ duration: 25, intensity: 0.7 }],
options?: TriggerOptions,
Expand Down Expand Up @@ -186,11 +191,11 @@ export class WebHaptics {
}
}

if (WebHaptics.isSupported) {
if (WebHaptics.supportsVibrationAPI) {
navigator.vibrate(toVibratePattern(vibrations, defaultIntensity));
}

if (!WebHaptics.isSupported || this.debug) {
if (!WebHaptics.supportsVibrationAPI || this.debug) {
this.ensureDOM();
if (!this.hapticLabel) return;

Expand Down Expand Up @@ -222,7 +227,7 @@ export class WebHaptics {

cancel(): void {
this.stopPattern();
if (WebHaptics.isSupported) {
if (WebHaptics.supportsVibrationAPI) {
navigator.vibrate(0);
}
}
Expand Down
2 changes: 1 addition & 1 deletion site/src/surfaces/docs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const methods = [
{
signature: "WebHaptics.isSupported: boolean",
description:
"Static property. Returns true if the device supports the Vibration API.",
"Static property. Returns true if the device supports haptics (touch devices such as iOS and Android)",
},
];

Expand Down