Battery

Updated: Oct 26, 2026

Overview

Web Apps can read the battery level and charging state on Meta Ray-Ban Display glasses through the standard Battery Status API⁠. Use it to scale back optional work when the battery runs low or show the charge in your own UI. There is no additional SDK to install.

Read the battery state

navigator.getBattery() returns a promise that resolves to a BatteryManager. Feature-detect it first so your app keeps working in browsers that do not support it.
async function watchBattery() {
  if (typeof navigator.getBattery !== 'function') {
    showBatteryUnavailable();
    return;
  }

  let battery;
  try {
    battery = await navigator.getBattery();
  } catch (error) {
    showBatteryUnavailable();
    return;
  }
  renderBattery(battery);
  //`levelchange` and `chargingchange` fire when these values change, so you do not need to poll them

  battery.addEventListener('levelchange', () => renderBattery(battery));
  battery.addEventListener('chargingchange', () => renderBattery(battery));
}

function renderBattery(battery) {
  // 'level' can take a value between 0 and 1
  const percent = Math.round(battery.level * 100);
  // 'charging' is set to 'true' while glasses are charging
  showBattery(`${percent}%${battery.charging ? ' (charging)' : ''}`);
}

Adapt to battery state

  • Treat the battery level as a hint for your own work, like lowering a refresh rate or pausing an animation.
  • Re-read values when your app becomes visible again (visibilitychange).