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

@tomaszatoo/ngx-user-camera

v0.0.3

Published

An Angular (zoneless 20+) Library to use devices's camera.

Readme

📸 UserCamera Angular Library

A modern Angular 20+ component for accessing user cameras, supporting front/back (user/environment) switching, optional canvas rendering, and reactive signals — fully zoneless.


Features

  • 🎥 Access user camera via MediaStream API
  • 🔄 Toggle between front (user) and back (environment) camera
  • 🖌 Optional canvas rendering for overlays, filters, or capture
  • ⚡ Reactive Signals (WritableSignal) for state management
  • 🧩 Emits events for stream ready, canvas frame, facing mode change, and errors
  • 🧹 Automatic cleanup of tracks and animation frames on destroy
  • 🏗 Fully compatible with Zoneless Angular 20+

Installation

npm install @tomaszatoo/ngx-user-camera

Usage

Import the component

Standalone import:

import { UserCamera } from '@tomaszatoo/ngx-user-camera';

@Component({
  selector: 'app-demo',
  standalone: true,
  imports: [UserCamera],
  template: `<user-camera></user-camera>`
})
export class DemoComponent {}

NgModule import:

import { UserCamera } from '@tomaszatoo/ngx-user-camera';

@NgModule({
  declarations: [UserCamera],
  exports: [UserCamera]
})
export class SharedModule {}

Template example

<user-camera
  [useCanvas]="true"
  [facingMode]="cameraMode"
  (facingModeChange)="cameraMode = $event"
  (streamInitialised)="onStream($event)"
  (canvasRender)="onCanvas($event)"
  (error)="onError($event)">
</user-camera>

<button (click)="cameraMode = cameraMode === 'user' ? 'environment' : 'user'">
  Flip Camera
</button>

Inputs

| Name | Type | Default | Description | |------|------|---------|-------------| | useCanvas | boolean | false | Whether to render the video on a canvas | | constraints | MediaStreamConstraints | { audio: false, video: true } | MediaStream constraints | | facingMode | 'user' \| 'environment' | 'user' | Camera facing mode (front/back) | |


Outputs

| Name | Type | Description | |------|------|-------------| | facingModeChange | EventEmitter<'user' \| 'environment'> | Emits when facing mode changes | | streamInitialised | EventEmitter<MediaStream> | Emits the camera MediaStream once ready | | canvasRender | EventEmitter<CanvasRenderingContext2D> | Emits canvas context for each frame | | error | EventEmitter<Error> | Emits any errors (permission denied, device missing, or unsupported features) |


Example Component

export class DemoComponent {
  cameraMode: 'user' | 'environment' = 'user';

  onStream(stream: MediaStream) {
    console.log('Camera stream ready', stream);
  }

  onCanvas(ctx: CanvasRenderingContext2D) {
    // Draw overlays or filters
  }

  onError(error: Error) {
    console.error('Camera error', error);
  }

  toggleCamera() {
    this.cameraMode = this.cameraMode === 'user' ? 'environment' : 'user';
  }
}

Notes

  • Works best on modern browsers that support MediaDevices.getUserMedia.
  • useCanvas allows custom rendering or photo capture from video.
  • Signals-based state means zero NgZone overhead for zoneless apps.
  • Always handle error output for devices without camera switching support.

Developer Setup

The following instructions assume you have Node ≥ 20 and the Angular CLI installed globally.
If you don’t have the CLI yet, install it first:

npm i -g @angular/cli

1. Clone the repository

git clone https://codeberg.org/tomaszatoo/ngx-user-camera.git
cd ngx-user-camera

2. Install dependencies

npm ci

npm ci installs exactly the versions specified in package-lock.json, ensuring reproducible builds.

3. Run the example app

The repository ships with an example Angular app that demonstrates how to use the library.
Start it with:

ng serve --open

This will:

  • Compile the library in development mode.
  • Spin up the example app on http://localhost:4200/.
  • Open the default browser automatically.

4. Build the library for distribution

When you’re ready to test a production build or publish the package, run:

npm run build --project @tomaszatoo/ngx-user-camera

The compiled output lives in dist/ngx-user-camera and can be used locally with:

npm install ../dist/ngx-user-camera

5. Run tests, lint, and format

# Unit tests
npm run test

6. Publish to npm (optional)

If you’re the package maintainer, you can publish the built library with:

cd dist/tomaszatoo/ngx-user-camera
npm publish --access public

Make sure you’re logged in to npm (npm login) and have the correct publish access.


Happy hacking! 🚀

License

MIT © 2025 Tomas Zato