navigator.vibrate() pulses phone (and some tablet) vibration hardware. Learn single-duration vs pattern arrays, how to cancel, user-activation rules, five examples, and try-it labs best tested on a real mobile device.
01
Kind
Method
02
Returns
boolean
03
Status
Limited (not Baseline)
04
Needs
User activation
05
Pattern
ms or array
06
Cancel
vibrate(0)
Fundamentals
Introduction
Games, chat apps, and form errors often give a short haptic pulse so the user feels feedback without staring at the screen. The Vibration API exposes that through navigator.vibrate().
Pass one number (vibrate that many milliseconds) or an array that alternates vibrate and pause. A new call replaces any pattern already running. Call it from a user gesture (button click). Silent / Do Not Disturb modes may block physical vibration even when the method returns true.
💡
No Dep / Exp / Non-standard banner
MDN marks Limited availability and sticky user activation, but not Deprecated, Experimental, or Non-standard. Always feature-detect and prefer short, purposeful patterns.
Concept
Understanding the vibrate() Method
One argument — a number of milliseconds, or an array of ms values.
Array meaning — [vibrate, pause, vibrate, pause, …].
Replace previous — a new call stops the old pattern and starts the new one.
Cancel — 0, [], or [0] stops vibration.
Return value — true if parameters are valid; false if invalid.
No hardware — desktop / missing vibrator: usually no effect (still may return true).
Foundation
📝 Syntax
General form of the method:
JavaScript
navigator.vibrate(pattern)
Parameters
pattern — a single number (ms) or an array of numbers alternating vibrate / pause.
Return value
true if the vibration was successfully started (or canceled with a valid cancel pattern).
Vibration is easiest to feel on a phone. Desktop browsers may return true with no haptic effect. Always call from a button click so user activation is present.
📚 Getting Started
Detect support and fire a short buzz from a click.
Example 1 — Feature Detection
Check whether the Vibration API method exists.
JavaScript
const lines = [
"vibrate: " +
(typeof navigator.vibrate === "function" ? "available" : "missing"),
"tip: test on a phone after a button click"
];
console.log(lines.join("\n"));
vibrate: available
tip: test on a phone after a button click
(or missing on some desktop / Safari setups)
How It Works
If the method is missing, skip haptic UI — do not treat it as an error.
Example 2 — Vibrate 200ms (MDN)
Simplest pattern: one short pulse from a button click.
JavaScript
function buzzShort() {
if (typeof navigator.vibrate !== "function") {
return "API not supported";
}
const ok = navigator.vibrate(200);
return ok ? "vibrate(200) accepted" : "vibrate(200) rejected";
}
// Call buzzShort() from a button click handler
navigator.vibrate() is part of the Vibration API and is not Baseline. Support is strongest on Android Chromium browsers. Many desktop browsers expose the method with no hardware effect; Safari support has historically been limited or absent. Always feature-detect and test on a real phone.
✓ Limited · Not Baseline
Navigator.vibrate()
Boolean → pulse vibration hardware with ms / pattern arrays.
LimitedNot Baseline
Google ChromeStrong on Android; desktop often no haptic
Limited
Microsoft EdgeFollow Chromium / device hardware
Limited
OperaFollow Chromium where available
Limited
Mozilla FirefoxAndroid support; desktop limited
Limited
Apple SafariHistorically unavailable / limited — feature-detect
Unavailable
Internet ExplorerNo Vibration API
Unavailable
vibrate()Limited
Bottom line: Detect the method, call from a user gesture, keep patterns short, cancel with vibrate(0), and never rely on haptics as the only feedback.
Wrap Up
Conclusion
navigator.vibrate() is the Vibration API way to give short haptic feedback. Feature-detect it, call it from a user gesture, prefer brief patterns, and cancel with vibrate(0) when needed.
Limited Vibration API — short haptic pulses from a user gesture.
5
Core concepts
📱01
Pulses
device vibrator
Haptic
📊02
Support
Limited
Not Baseline
👋03
Needs
user gesture
Activation
📈04
Pattern
ms or array
On / pause
🚫05
Cancel
vibrate(0)
Stop
❓ Frequently Asked Questions
It pulses the device’s vibration hardware using a pattern of on/off intervals in milliseconds. If the device has no vibrator, the call has no physical effect.
No. MDN does not mark it Deprecated, Experimental, or Non-standard. It is Limited availability (not Baseline). No status banner is required.
Sticky user activation is required. Call vibrate from a button click or similar UI interaction — not from page load or a timer alone.
true means the call was accepted (parameters valid). false means invalid parameters. true does not guarantee you will feel vibration (Silent/DND mode, desktop, or no hardware).
Call navigator.vibrate(0), navigator.vibrate([]), or navigator.vibrate([0]). A new pattern also replaces any pattern already running.
A number vibrates once for that many ms. An array alternates vibrate and pause: [vibrate, pause, vibrate, …]. MDN’s SOS Morse example uses a longer array.
Did you know?
If a vibration is already running, calling vibrate() again does not queue a second pattern — it halts the old one and starts the new pattern immediately.