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

@capawesome/capacitor-torch

v8.0.1

Published

Capacitor plugin for switching the flashlight on and off.

Readme

@capawesome/capacitor-torch

Capacitor plugin for switching the flashlight on and off.

Features

We are proud to offer one of the most complete and feature-rich Capacitor plugins for torch/flashlight control. Here are some of the key features:

  • 🖥️ Cross-platform: Supports Android, iOS, and Web.
  • 🔦 Torch control: Enable, disable, and toggle torch/flashlight.
  • Availability check: Check if torch is available on the device.
  • 🌐 Web support: Uses MediaStream API for web torch control.
  • 🔁 Up-to-date: Always supports the latest Capacitor version.

Missing a feature? Just open an issue and we'll take a look!

Newsletter

Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our Capawesome Newsletter.

Compatibility

| Plugin Version | Capacitor Version | Status | | -------------- | ----------------- | -------------- | | 8.x.x | >=8.x.x | Active support |

Installation

npm install @capawesome/capacitor-torch
npx cap sync

Android

Permissions

This API requires the following permissions be added to your AndroidManifest.xml before the application tag:

<!-- To get access to the flashlight. -->
<uses-permission android:name="android.permission.FLASHLIGHT"/>

Variables

If needed, you can define the following project variable in your app’s variables.gradle file to change the default version of the dependency:

  • $androidxCameraCoreVersion version of androidx.camera:camera-core (default: 1.5.2)

This can be useful if you encounter dependency conflicts with other plugins in your project.

Configuration

No configuration required for this plugin.

Demo

A working example can be found here: robingenz/capacitor-plugin-demo

Usage

import { Torch } from '@capawesome/capacitor-torch';

const enable = async () => {
  await Torch.enable();
};

const disable = async () => {
  await Torch.disable();
};

const isAvailable = async () => {
    const result = await Torch.isAvailable();
    return result.available;
};

const isEnabled = async () => {
    const result = await Torch.isEnabled();
    return result.enabled;
};

const toggle = async () => {
  await Torch.toggle();
};

API

enable(...)

enable(options?: EnableOptions | undefined) => Promise<void>

Enable the torch.

Only available on Android (SDK 23+), iOS and Web.

| Param | Type | | ------------- | ------------------------------------------------------- | | options | EnableOptions |

Since: 6.0.0


disable(...)

disable(options?: DisableOptions | undefined) => Promise<void>

Disable the torch.

Only available on Android (SDK 23+), iOS and Web.

| Param | Type | | ------------- | --------------------------------------------------------- | | options | DisableOptions |

Since: 6.0.0


isAvailable()

isAvailable() => Promise<IsAvailableResult>

Check if the torch is available.

Only available on Android, iOS and Web.

Returns: Promise<IsAvailableResult>

Since: 6.0.0


isEnabled(...)

isEnabled(options?: IsEnabledOptions | undefined) => Promise<IsEnabledResult>

Check if the torch is enabled.

Only available on Android, iOS and Web.

| Param | Type | | ------------- | ------------------------------------------------------------- | | options | IsEnabledOptions |

Returns: Promise<IsEnabledResult>

Since: 6.0.0


toggle(...)

toggle(options?: ToggleOptions | undefined) => Promise<void>

Toggle the torch.

Only available on Android (SDK 23+), iOS and Web.

| Param | Type | | ------------- | ------------------------------------------------------- | | options | ToggleOptions |

Since: 6.0.0


Interfaces

EnableOptions

| Prop | Type | Description | Since | | ------------ | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- | | stream | MediaStream | The stream of media to enable the torch on. Attention: The stream must have a video track. The facing mode of the video track must be the one that corresponds to the torch. Only available on Web. | 6.2.0 |

DisableOptions

| Prop | Type | Description | Since | | ------------ | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- | | stream | MediaStream | The stream of media to disable the torch on. Attention: The stream must have a video track. The facing mode of the video track must be the one that corresponds to the torch. Only available on Web. | 6.2.0 |

IsAvailableResult

| Prop | Type | Description | Since | | --------------- | -------------------- | -------------------------------------- | ----- | | available | boolean | Whether the torch is available or not. | 6.0.0 |

IsEnabledResult

| Prop | Type | Description | Since | | ------------- | -------------------- | ------------------------------------ | ----- | | enabled | boolean | Whether the torch is enabled or not. | 6.0.0 |

IsEnabledOptions

| Prop | Type | Description | Since | | ------------ | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- | | stream | MediaStream | The stream of media to check if the torch is enabled on. Attention: The stream must have a video track. The facing mode of the video track must be the one that corresponds to the torch. Only available on Web. | 6.2.0 |

ToggleOptions

| Prop | Type | Description | Since | | ------------ | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- | | stream | MediaStream | The stream of media to toggle the torch on. Attention: The stream must have a video track. The facing mode of the video track must be the one that corresponds to the torch. Only available on Web. | 6.2.0 |

Changelog

See CHANGELOG.md.

License

See LICENSE.