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

use-simple-camera

v2.0.1

Published

Production-ready React Hooks for Camera, Video Recording, QR/Barcode Scanning, Motion Detection, and Audio Analysis. Zero dependencies, fully typed, and easy to use.

Readme

🎥 Use Simple Camera

NPM Version Build Status Minzipped Size Dependencies TypeScript License: MIT Style: Biome Socket Badge npm downloads PRs Welcome FOSSA Status Snyk

Gitpod Ready semantic-release Contributor Covenant

Use Simple Camera is a production-ready, zero-dependency React hook library for comprehensive camera and media handling. It provides a robust set of hooks for video recording, local/remote storage, computer vision (barcodes, motion detection), and hardware controls (zoom, flash, pan, tilt).

✨ Features

  • 📸 Easy Camera Access: Simple API to get camera stream, switch cameras, and capture images.
  • 🎥 Video Recording: Record video/audio blobs with MediaRecorder API.
  • 💾 Storage: Save recordings to IndexedDB or upload via XHR/S3.
  • 🔍 Computer Vision: Built-in hooks for Barcode detection and Motion detection.
  • 🛠 Hardware Controls: Control Zoom, Flash, Pan, and Tilt if supported.
  • 🎙 Audio Utilities: Monitor microphone volume levels in real-time.
  • 📱 Orientation: Detect device orientation for responsive UI.
  • 🌲 Tree Shakeable: Import only the hooks you need.

📦 Installation

npm install /use-simple-camera
# or
pnpm add /use-simple-camera
# or
yarn add /use-simple-camera

Quick Start

The useSimpleCamera hook is the entry point that composes most features, but you can use individual hooks as standalone primitives.

import { useSimpleCamera } from "/use-simple-camera";

const App = () => {
  const { stream, ref, error, startCamera, captureImage } = useSimpleCamera();
  
  if (error) return <p>Error: {error.message}</p>;

  return (
    <div>
       <video ref={ref} autoPlay muted playsInline />
       <button onClick={() => captureImage()}>Take Photo</button>
    </div>
  );
};

📚 API Documentation

1. useSimpleCamera

The main hook for managing camera lifecycle, permissions, and stream state.

| Property | Type | Description | | :--- | :--- | :--- | | stream | MediaStream \| null | The active camera stream. | | startCamera | (constraints?) => Promise | Manually starts the camera. | | stopCamera | () => void | Stops all tracks and releases camera. | | captureImage | (options?) => string | Captures a base64 image. | | error | CameraError \| null | Typed error object if something fails. | | isCameraActive | boolean | True if stream is active. | | switchCamera | () => void | Toggles between front and back cameras. |

2. useRecorder

Handles video and audio recording with support for separate streams and callbacks.

import { useRecorder } from "use-simple-camera";
const { startRecording, stopRecording, isRecording } = useRecorder(stream);

| Property | Type | Description | | :--- | :--- | :--- | | startRecording | (options?) => void | Starts recording media. Options: mode, onComplete. | | stopRecording | () => void | Stops recording and triggers onComplete with blob. | | takeSnapshot | () => Promise<Blob> | Captures a high-res still photo. |

3. useStorage

Manage local persistence (IndexedDB) and remote uploads (S3/XHR).

import { useStorage } from "use-simple-camera";
const { saveToLocal, uploadToRemote } = useStorage();

| Property | Type | Description | | :--- | :--- | :--- | | saveToLocal | (blob, name, opts) => Promise | Save blob to IndexedDB with optional retention. | | getFromLocal | (name) => Promise<Blob> | Retrieve blob from IndexedDB. | | uploadToRemote | (blob, opts) => Promise | Upload to signed URL. Options: headers, timeout, etc. |

4. useCameraControls

Control hardware features like Zoom, Flash, Pan, and Tilt.

import { useCameraControls } from "use-simple-camera";
const { zoom, setZoom, flash, setFlash, supports } = useCameraControls(stream);

5. useBarcodeScanner

Detects QR codes and Barcodes in real-time.

const { barcodes, isScanning } = useBarcodeScanner(stream, { formats: ['qr_code'] });

6. useMotionDetection

Detects movement in the video feed using pixel differencing.

const { motionDetected } = useMotionDetection(stream, { threshold: 10 });

7. useAudioLevel

Monitors real-time microphone volume.

const { volume } = useAudioLevel(stream); // 0-100

8. useOrientation

Tracks device screen orientation.

const { orientation, angle } = useOrientation(); // 'portrait' | 'landscape'

9. useMediaDevices

Enumerates available audio and video inputs.

const { videoDevices, audioDevices } = useMediaDevices();

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

This project is licensed under the MIT License.