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-flashlight

v0.1.0

Published

Expo module to control the device torch (flashlight): on/off and brightness.

Readme

expo-flashlight

Expo module to control the device torch (flashlight): turn it on/off and adjust its brightness.

  • iOS — continuous brightness via AVCaptureDevice.setTorchModeOn(level:).
  • Android — on/off via CameraManager.setTorchMode; adjustable brightness on Android 13+ (API 33) via turnOnTorchWithStrengthLevel, with automatic on/off fallback on older devices.
  • Web — reports the torch as unavailable (control is not supported).

Installation

npx expo install expo-flashlight

This is a native module, so it requires a development build — it does not run in Expo Go.

Usage

import Flashlight from 'expo-flashlight';

if (Flashlight.isAvailable()) {
  Flashlight.enable();           // turn on (last/full brightness)
  Flashlight.setBrightness(0.5); // 50% brightness (0..1)
  Flashlight.toggle();           // flip on/off, returns the new state

  if (Flashlight.isOn) {
    Flashlight.disable();        // turn off
  }
}

Reacting to state changes

import Flashlight, { ExpoFlashlightModule } from 'expo-flashlight';
import { useEvent } from 'expo';

function TorchStatus() {
  const state = useEvent(ExpoFlashlightModule, 'onTorchStateChanged');
  // state?.enabled, state?.brightness
}

Or imperatively:

const sub = Flashlight.addListener(({ enabled, brightness }) => {
  console.log({ enabled, brightness });
});
// later
sub.remove();

API

| Member | Type | Description | | --- | --- | --- | | isAvailable() | boolean | Whether the device has a controllable torch. | | isBrightnessControlAvailable() | boolean | Whether brightness can be adjusted (always on iOS with a torch; Android 13+ only). | | enable(brightness?) | void | Turn the torch on. Optional 0..1 brightness. | | disable() | void | Turn the torch off. | | toggle() | boolean | Toggle the torch; returns the new on/off state. | | set(on) | void | Set the torch on or off. | | setBrightness(level) | void | Set brightness 0..1. 0 turns the torch off. | | getBrightness() | number | Current brightness 0..1 (0 when off). | | isOn / isOff | boolean (getter) | Whether the torch is currently on/off. | | isEnabled() | boolean | Method form of isOn. | | addListener(cb) | EventSubscription | Subscribe to { enabled, brightness } changes. |

Brightness on Android

Below Android 13 the torch is on/off only, so setBrightness(level) turns the torch on at full brightness for any level > 0. On Android 13+ the normalized 0..1 value is mapped to the device's discrete strength steps. Use isBrightnessControlAvailable() to detect support.

Development

This package uses Bun as its package manager.

bun install      # install dependencies
bun run build    # compile src/ -> build/
bun run lint     # eslint
bun run test     # run the Vitest suite once
bun run test:watch

Unit tests live in src/__tests__/ and use Vitest. The native module is mocked, so the tests cover the JavaScript wrapper logic (brightness clamping, delegation, getters, event subscription) without a device.

License

MIT © Aziz Becha