npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

expo-hardware-buttons

v1.0.1

Published

Expo native module for listening to physical hardware button events on iOS: Camera Control button and volume buttons.

Readme

expo-hardware-buttons

An Expo native module for listening to physical hardware button events on iOS.

  • Camera Control button — iPhone 16 and later (iOS 17.2+)
  • Volume buttons — all iOS devices

Installation

npm install expo-hardware-buttons

Then rebuild your native project:

npx expo run:ios

Expo autolinking will pick up the module automatically — no manual pod or config changes required.

Requirements

| Feature | Minimum | |---|---| | Expo SDK | 52+ | | iOS | 15.1+ | | Camera Control button | iOS 17.2+, iPhone 16 / 16 Pro or later | | Volume buttons | All iOS devices |

Quick Start

import HardwareButtonsModule from 'expo-hardware-buttons';
import { useEffect } from 'react';

export default function CameraScreen() {
  useEffect(() => {
    // Keep the Camera Control button claimed by your app
    HardwareButtonsModule.attachCameraButton();
    return () => HardwareButtonsModule.detachCameraButton();
  }, []);

  useEffect(() => {
    const volumeSub = HardwareButtonsModule.addListener('onVolumeButton', (event) => {
      console.log('Volume button:', event.direction); // 'up' | 'down'
      takePhoto();
    });

    const cameraSub = HardwareButtonsModule.addListener('onCameraButton', (event) => {
      console.log('Camera button:', event.action); // 'press' | 'longPress'
      takePhoto();
    });

    return () => {
      volumeSub.remove();
      cameraSub.remove();
    };
  }, []);

  // ...
}

API

getCapabilitiesAsync()

Returns the hardware button capabilities of the current device.

const caps = await HardwareButtonsModule.getCapabilitiesAsync();
// { hasCameraButton: boolean, hasVolumeButtons: boolean }

| Property | Type | Description | |---|---|---| | hasCameraButton | boolean | true on iPhone 16+ running iOS 17.2+ | | hasVolumeButtons | boolean | true on all iOS devices |

attachCameraButton()

Installs an AVCaptureEventInteraction on the root view so the Camera Control button fires events to your app instead of opening the system Camera. Call this when your camera screen mounts.

detachCameraButton()

Removes the interaction. Call this in your cleanup/unmount to release the button back to the system.

Events

onCameraButton

Fired when the Camera Control button is pressed.

HardwareButtonsModule.addListener('onCameraButton', (event) => {
  event.action; // 'press' | 'longPress'
  event.phase;  // 'ended'
});

onVolumeButton

Fired when a volume button is pressed. The system volume HUD is suppressed and volume level is automatically restored so repeated presses don't drift to 0 or max.

HardwareButtonsModule.addListener('onVolumeButton', (event) => {
  event.direction; // 'up' | 'down'
});

How It Works

Camera Control Button

Uses AVCaptureEventInteraction (iOS 17.2+) attached to the app's root view. While the interaction is active, the system routes Camera Control button presses to your app instead of launching the built-in Camera.

Volume Buttons

Observes AVAudioSession.outputVolume via KVO. A hidden MPVolumeView is added to the window to suppress the system volume HUD. After each press, the volume is silently restored to its original level so the user can press repeatedly without the volume drifting.

Types

type CameraButtonAction = 'press' | 'longPress';
type CameraButtonPhase = 'ended';
type VolumeDirection = 'up' | 'down';

type CameraButtonEventPayload = {
  action: CameraButtonAction;
  phase: CameraButtonPhase;
};

type VolumeButtonEventPayload = {
  direction: VolumeDirection;
};

type HardwareButtonsCapabilities = {
  hasCameraButton: boolean;
  hasVolumeButtons: boolean;
};

Platform Support

iOS only. This module has no Android implementation. On Android, volume button handling is typically done at the Activity level and the Camera Control button does not exist.

License

MIT