Skip to main content
The Vibration API provides access to the device’s vibration functionality. You can trigger single vibrations or pattern-based vibrations.

Methods

vibrate()

Triggers a vibration with the specified pattern.
number | number[]
default:"400"
Vibration pattern:
  • number: Duration in milliseconds to vibrate
  • array: Pattern of durations alternating between vibrate and pause
    • Example: [0, 500, 200, 500] means:
      • Wait 0ms
      • Vibrate 500ms
      • Pause 200ms
      • Vibrate 500ms
boolean
default:"false"
Whether to repeat the vibration pattern. Only applies when pattern is an array.Android: Repeats from the first vibration (index 0)iOS: Repeats the entire pattern

Platform Differences

Android

  • Supports both single vibrations and pattern arrays
  • Pattern arrays are passed directly to the native module
  • Repeat behavior starts from index 0
  • Requires VIBRATE permission in AndroidManifest.xml:

iOS

  • Supports single vibrations and pattern arrays
  • Pattern arrays are processed in JavaScript with scheduling
  • Default vibration duration is 400ms regardless of the number passed
  • No permissions required

cancel()

Stops any ongoing vibration. Android: Calls the native cancel method iOS: Sets internal flag to stop scheduled vibrations

Examples

Single Vibration

Default Vibration

Pattern Vibration

Repeating Pattern

Custom Alert Pattern

SOS Pattern

Notes

  • On iOS, the vibration duration cannot be customized; the device will always vibrate for approximately 400ms
  • Android allows custom duration vibrations
  • Always call cancel() when stopping a repeating vibration pattern
  • Excessive vibration can drain battery and annoy users - use judiciously
  • Test vibration patterns on physical devices as simulators/emulators may not support vibration