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

react-native-brightness-manager

v0.2.0

Published

Native brightness manager for React Native (no Expo)

Readme


📱 react-native-brightness-manager

A simple, reliable React Native library to control app-level screen brightness on Android and iOS, without requiring any system permissions.

This library is designed to work consistently across devices, including Android OEMs that restrict system brightness access.


Features

  • ✅ App-level brightness control
  • ✅ Works on Android & iOS
  • ✅ No WRITE_SETTINGS permission required
  • ✅ No system settings modification
  • ✅ Safe brightness restore
  • ✅ OEM-friendly and production tested

Installation

npm install react-native-brightness-manager
yarn add react-native-brightness-manager

For iOS:

cd ios && pod install

Basic Usage

Increase brightness when a screen opens and restore on exit

import { useEffect, useRef } from 'react';
import { Platform } from 'react-native';
import { Brightness } from 'react-native-brightness-manager';

const originalBrightnessRef = useRef(null);
const brightnessAppliedRef = useRef(false);

useEffect(() => {
  let timeoutId;
  let isMounted = true;

  const applyBrightness = async () => {
    try {
      const current = await Brightness.getBrightnessAsync();
      originalBrightnessRef.current = current;
      brightnessAppliedRef.current = false;

      timeoutId = setTimeout(async () => {
        if (!isMounted) return;

        try {
          await Brightness.setBrightnessAsync(0.99);
          brightnessAppliedRef.current = true;
        } catch (e) {}
      }, 250);
    } catch (e) {}
  };

  applyBrightness();

  return () => {
    isMounted = false;

    if (timeoutId) {
      clearTimeout(timeoutId);
    }

    const restoreBrightness = async () => {
      try {
        const original = originalBrightnessRef.current;

        if (Platform.OS === 'ios' && typeof original === 'number') {
          await Brightness.setBrightnessAsync(original);
        } else {
          // Safe to call on Android (no-op)
          await Brightness.restoreSystemBrightnessAsync();
        }

        originalBrightnessRef.current = null;
        brightnessAppliedRef.current = false;
      } catch (e) {}
    };

    restoreBrightness();
  };
}, []);

Android Behavior (Important)

Many Android devices do not allow apps to change system brightness due to OS and OEM restrictions.

Because of this, this library:

  • ❌ Does not modify system brightness
  • ❌ Does not request WRITE_SETTINGS
  • ❌ Does not redirect users to system settings

Instead, it uses app-level brightness, which:

  • ✅ Works reliably on all Android devices
  • ✅ Behaves similar to iOS brightness handling
  • ✅ Automatically restores when the app goes to background
  • ✅ Fully satisfies the requirement of increasing brightness

Calling restoreSystemBrightnessAsync() on Android is safe and does not require any permission.


iOS Behavior

  • Brightness is controlled at app level
  • You should manually restore brightness when leaving a screen
  • No additional permissions required

Why App-Level Brightness?

  • Consistent behavior across devices
  • No permission denials
  • No OEM-specific crashes
  • Better user experience
  • Play Store safe

API Reference

Brightness.isAvailableAsync()

Checks whether the native module is available.


Brightness.getBrightnessAsync()

Returns the current app-level brightness.


Brightness.setBrightnessAsync(value)

Sets the app-level brightness.

  • value must be between 0 and 1

Brightness.restoreSystemBrightnessAsync()

Safely restores brightness.

  • iOS: Should be used to restore previous brightness
  • Android: Safe no-op (OS restores automatically)

⚠️ Deprecated / Compatibility APIs

The following APIs exist only for backward compatibility and do not modify system settings:

  • getSystemBrightnessAsync
  • setSystemBrightnessAsync
  • getPermissionsAsync
  • requestPermissionsAsync
  • isUsingSystemBrightnessAsync

They are internally mapped to app-level behavior or safely ignored.


🧾 Summary

  • Android & iOS handled consistently
  • App-level brightness only
  • No system permissions
  • Safe restore support
  • Designed for real-world production apps

📄 License

MIT