Skip to main content
@capgo/capacitor-flash Media Open source

Flash Capacitor plugin

Control device flashlight and torch with simple on/off toggle functionality

Install

bun add @capgo/capacitor-flash bunx cap sync
npm, pnpm or yarn
  • npm install @capgo/capacitor-flash
  • pnpm add @capgo/capacitor-flash
  • yarn add @capgo/capacitor-flash

Guide

How to use Flash in Capacitor

Test on device

Download the Capgo app, then scan the QR code.

Flash plugin preview QR code

Using @capgo/capacitor-flash

Capacitor Flash Plugin for controlling device flashlight/torch.

Install

bun add @capgo/capacitor-flash
bunx cap sync

bunx cap sync copies the plugin's native code into your native projects. Run it again after every plugin upgrade.

Import

import { CapacitorFlash } from '@capgo/capacitor-flash';

API at a glance

Method Description
isAvailable Checks if flashlight is available on the device.
switchOn Turns the flashlight on.
switchOff Turns the flashlight off.
isSwitchedOn Checks if the flashlight is currently turned on or off.
toggle Toggle the flashlight on or off.

Examples

isAvailable()

Checks if flashlight is available on the device.

import { CapacitorFlash } from '@capgo/capacitor-flash';

const { value } = await CapacitorFlash.isAvailable();
if (value) {
  console.log('Flashlight is available');
}

switchOn()

Turns the flashlight on.

import { CapacitorFlash } from '@capgo/capacitor-flash';

// Turn on at full brightness
await CapacitorFlash.switchOn({ intensity: 1.0 });

// Turn on at half brightness
await CapacitorFlash.switchOn({ intensity: 0.5 });

switchOff()

Turns the flashlight off.

import { CapacitorFlash } from '@capgo/capacitor-flash';

await CapacitorFlash.switchOff();

isSwitchedOn()

Checks if the flashlight is currently turned on or off.

import { CapacitorFlash } from '@capgo/capacitor-flash';

const { value } = await CapacitorFlash.isSwitchedOn();
console.log('Flashlight is on:', value);

toggle()

Toggle the flashlight on or off.

import { CapacitorFlash } from '@capgo/capacitor-flash';

const { value } = await CapacitorFlash.toggle();
console.log('Flashlight toggled, now on:', value);

Full reference

Keep going from Using @capgo/capacitor-flash

If you are using Using @capgo/capacitor-flash to plan dashboard and API operations, connect it with @capgo/capacitor-flash for the implementation detail in @capgo/capacitor-flash, Getting Started for the implementation detail in Getting Started, API Overview for the implementation detail in API Overview, Introduction for the implementation detail in Introduction, and API Keys for the implementation detail in API Keys.

FAQ

Flash plugin FAQ

How do I install the Flash plugin in a Capacitor app?

Run "bun add @capgo/capacitor-flash" (or "npm install @capgo/capacitor-flash"), then run "bunx cap sync" so the iOS and Android projects pick up the native code. Import it from "@capgo/capacitor-flash" in your app code.

Does @capgo/capacitor-flash work with React, Vue and Angular?

Yes. Flash is a Capacitor package, so it works with any web framework that runs inside Capacitor, including Ionic, React, Vue, Angular, Svelte and plain JavaScript.

Which Capacitor version does @capgo/capacitor-flash support?

Capgo plugins follow Capacitor's major version: use the plugin major version that matches your Capacitor major version (for example plugin v8 with Capacitor 8). The compatibility table in the GitHub README lists the maintained versions.

Is @capgo/capacitor-flash free and open source?

Yes. The source code is public on GitHub at https://github.com/Cap-go/capacitor-flash/ and the package is free to install from npm. Bug reports and pull requests are welcome.

Can I update code that uses Flash without an App Store review?

Installing or upgrading the plugin changes native code, so it needs a new store build. After that, JavaScript, HTML and CSS changes that call the plugin can ship instantly with Capgo live updates.

Ship Flash changes without waiting for app review

Once the plugin is in your store build, Capgo live updates push your JavaScript, HTML and CSS changes to users in minutes.

Start with Capgo