Vue NativeVue Native
Guide
Components
Composables
Navigation
Architecture
  • iOS
  • Android
  • macOS
GitHub
Guide
Components
Composables
Navigation
Architecture
  • iOS
  • Android
  • macOS
GitHub
  • Device & System

    • useNetwork
    • useAppState
    • useColorScheme
    • useDeviceInfo
    • useBattery
    • useDimensions
    • usePlatform
  • Storage & Files

    • useAsyncStorage
    • useSecureStorage
    • useFileSystem
    • useDatabase
  • Sensors & Hardware

    • useGeolocation
    • useBiometry
    • useHaptics
    • useSensors
    • useBluetooth
  • Media

    • useCamera
    • useImagePicker
    • useAudio
    • useCalendar
    • useContacts
  • Networking

    • useHttp
    • useWebSocket
  • Permissions

    • usePermissions
  • Navigation

    • useBackHandler
    • useSharedElementTransition
  • UI

    • useKeyboard
    • useClipboard
    • useAccessibility
    • useShare
    • useLinking
    • useAnimation
    • useGesture
    • useTeleport
    • useNotifications
    • useI18n
    • usePerformance
    • useInspector
  • Authentication

    • useAppleSignIn
    • useGoogleSignIn
  • Monetization & Updates

    • useIAP
    • useOTAUpdate
    • useBackgroundTask
  • Desktop (macOS)

    • useWindow
    • useMenu
    • useFileDialog
    • useDragDrop

useBattery

Reactive battery state — level and charging status. Backed by the native Battery module (UIDevice battery monitoring on iOS, BatteryManager on Android). On platforms without a battery (desktop Mac) the values stay null and isSupported is false.

API

const { level, isCharging, isSupported, refresh } = useBattery(options?)
ReturnTypeDescription
levelRef<number | null>Battery level 0..1, or null when unavailable.
isChargingRef<boolean | null>Whether the battery is charging, or null when unavailable.
isSupportedRef<boolean | null>false on devices without a battery.
refresh() => Promise<void>Manually re-read the battery state.
OptionTypeDefaultDescription
pollIntervalnumber60000Refresh interval in ms. 0 disables automatic polling.

Example

<script setup lang="ts">
import { useBattery, VText, VView } from '@thelacanians/vue-native-runtime'

const { level, isCharging, isSupported } = useBattery()
</script>

<template>
  <VView v-if="isSupported">
    <VText>Battery: {{ Math.round((level ?? 0) * 100) }}%</VText>
    <VText>{{ isCharging ? 'Charging' : 'Not charging' }}</VText>
  </VView>
  <VText v-else>Battery info not available on this device.</VText>
</template>

Notes

  • The state is read on mount and refreshed every pollInterval ms.
  • Set pollInterval: 0 and call refresh() yourself for on-demand reads.
Edit this page
Last Updated: 7/28/26, 7:56 PM
Contributors: Abdul Hamid
Prev
useDeviceInfo
Next
useDimensions