https://github.com/Cap-go/capacitor-accelerometer
Capacitor plugin to read device accelerometer measurements
https://github.com/Cap-go/capacitor-accelerometer
Last synced: about 1 month ago
JSON representation
Capacitor plugin to read device accelerometer measurements
- Host: GitHub
- URL: https://github.com/Cap-go/capacitor-accelerometer
- Owner: Cap-go
- License: mpl-2.0
- Created: 2025-10-27T04:49:27.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2026-02-04T02:11:01.000Z (about 1 month ago)
- Last Synced: 2026-02-04T13:54:55.519Z (about 1 month ago)
- Language: Swift
- Size: 849 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Agents: AGENTS.md
Awesome Lists containing this project
- awesome-capacitor - Accelerometer - Read device accelerometer measurements. ([Capgo plugins](https://capgo.app/) / Device & Sensors)
README
# @capgo/capacitor-accelerometer

Access raw accelerometer measurements across iOS, Android, and the Web.
## Why Capacitor Accelerometer?
The only **free** and **maintained** Capacitor plugin for accelerometer access. Other plugins are either paid or no longer updated. This plugin provides:
- **Up-to-date implementation** - Uses the latest APIs across all platforms
- **Consistent JavaScript API** - Same interface as popular paid alternatives
- **Cross-platform** - Works on iOS, Android, and Web
- **Permission handling** - Built-in permission management
- **Real-time streaming** - Listen to continuous accelerometer updates
Perfect for fitness apps, games, gesture detection, and motion-based interfaces.
## Documentation
The most complete doc is available here: https://capgo.app/docs/plugins/accelerometer/
## Compatibility
| Plugin version | Capacitor compatibility | Maintained |
| -------------- | ----------------------- | ---------- |
| v8.\*.\* | v8.\*.\* | ✅ |
| v7.\*.\* | v7.\*.\* | On demand |
| v6.\*.\* | v6.\*.\* | ❌ |
| v5.\*.\* | v5.\*.\* | ❌ |
> **Note:** The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation (e.g., plugin v8 for Capacitor 8). Only the latest major version is actively maintained.
## Install
```bash
npm install @capgo/capacitor-accelerometer
npx cap sync
```
## API
* [`getMeasurement()`](#getmeasurement)
* [`isAvailable()`](#isavailable)
* [`startMeasurementUpdates()`](#startmeasurementupdates)
* [`stopMeasurementUpdates()`](#stopmeasurementupdates)
* [`checkPermissions()`](#checkpermissions)
* [`requestPermissions()`](#requestpermissions)
* [`addListener('measurement', ...)`](#addlistenermeasurement-)
* [`removeAllListeners()`](#removealllisteners)
* [`getPluginVersion()`](#getpluginversion)
* [Interfaces](#interfaces)
* [Type Aliases](#type-aliases)
Capacitor plugin contract for working with the device accelerometer.
### getMeasurement()
```typescript
getMeasurement() => Promise
```
Get the most recent accelerometer sample that was recorded by the native layer.
**Returns:** Promise<Measurement>
**Since:** 1.0.0
--------------------
### isAvailable()
```typescript
isAvailable() => Promise
```
Check if the current device includes an accelerometer sensor.
**Returns:** Promise<IsAvailableResult>
**Since:** 1.0.0
--------------------
### startMeasurementUpdates()
```typescript
startMeasurementUpdates() => Promise
```
Begin streaming accelerometer updates to the JavaScript layer.
Call {@link addListener} with the `measurement` event to receive the updates.
**Since:** 1.0.0
--------------------
### stopMeasurementUpdates()
```typescript
stopMeasurementUpdates() => Promise
```
Stop streaming accelerometer updates started via {@link startMeasurementUpdates}.
**Since:** 1.0.0
--------------------
### checkPermissions()
```typescript
checkPermissions() => Promise
```
Return the current permission state for accessing motion data.
On platforms without explicit permissions this resolves to `granted`.
**Returns:** Promise<PermissionStatus>
**Since:** 1.0.0
--------------------
### requestPermissions()
```typescript
requestPermissions() => Promise
```
Request permission to access motion data if supported by the platform.
**Returns:** Promise<PermissionStatus>
**Since:** 1.0.0
--------------------
### addListener('measurement', ...)
```typescript
addListener(eventName: 'measurement', listenerFunc: (event: MeasurementEvent) => void) => Promise
```
Listen for measurement updates.
| Param | Type | Description |
| ------------------ | ----------------------------------------------------------------------- | ------------------------------------------ |
| **`eventName`** | 'measurement' | Only the `measurement` event is supported. |
| **`listenerFunc`** | (event: Measurement) => void | Callback invoked with each measurement. |
**Returns:** Promise<PluginListenerHandle>
**Since:** 1.0.0
--------------------
### removeAllListeners()
```typescript
removeAllListeners() => Promise
```
Remove all listeners that have been registered on the plugin.
**Since:** 1.0.0
--------------------
### getPluginVersion()
```typescript
getPluginVersion() => Promise<{ version: string; }>
```
Get the native Capacitor plugin version.
**Returns:** Promise<{ version: string; }>
**Since:** 1.0.0
--------------------
### Interfaces
#### Measurement
The x, y and z axis acceleration values reported by the device motion sensors.
| Prop | Type | Description | Since |
| ------- | ------------------- | -------------------------------------- | ----- |
| **`x`** | number | The acceleration on the x-axis in G's. | 1.0.0 |
| **`y`** | number | The acceleration on the y-axis in G's. | 1.0.0 |
| **`z`** | number | The acceleration on the z-axis in G's. | 1.0.0 |
#### IsAvailableResult
Result returned by {@link CapacitorAccelerometerPlugin.isAvailable}.
| Prop | Type | Description | Since |
| ----------------- | -------------------- | ----------------------------------------------------------- | ----- |
| **`isAvailable`** | boolean | Whether an accelerometer sensor is available on the device. | 1.0.0 |
#### PermissionStatus
Permission information returned by {@link CapacitorAccelerometerPlugin.checkPermissions}
and {@link CapacitorAccelerometerPlugin.requestPermissions}.
| Prop | Type | Description | Since |
| ------------------- | ------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- | ----- |
| **`accelerometer`** | AccelerometerPermissionState | The permission state for accessing motion data on the current platform. | 1.0.0 |
#### PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| **`remove`** | () => Promise<void> |
### Type Aliases
#### GetMeasurementResult
Alias for the most recent measurement.
#### AccelerometerPermissionState
Permission state union including `limited` for platforms that can throttle motion access.
PermissionState | 'limited'
#### PermissionState
'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'
#### MeasurementEvent
Event payload emitted when {@link CapacitorAccelerometerPlugin.startMeasurementUpdates}
is active.
### Credit
This plugin was inspired from: https://github.com/kesha-antonov/react-native-background-downloader