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-livecheck

v1.0.1

Published

React library for person liveness detection — verify that a user is a real live person (e.g. face liveness, anti-spoofing) in web applications.

Readme

react-livecheck

React hook for person liveness detection — verify that a user is a real live person via blink detection (MediaPipe Face Mesh). Build your own UI; the hook handles camera, face detection, and pass/fail state.

Installation

pnpm add react-livecheck

Requirements

  • React 19 and peer dependency react
  • HTTPS in production (or localhost). Camera access requires a secure context; getUserMedia is blocked on plain HTTP.
  • Modern browser with navigator.mediaDevices and support for MediaPipe (Chrome, Firefox, Safari, Edge). Some corporate networks may block the default CDN; use a custom locateFile or self-host model files if needed.
  • Use one useLiveness instance per page (one camera stream). Multiple instances may conflict.

Usage

import { useLiveness, LivenessErrorCode } from "react-livecheck";

function LivenessScreen() {
  const {
    videoRef,
    blinkCount,
    passed,
    error,
    isReady,
    isFaceDetected,
    faceBoundingBox,
    retry,
  } = useLiveness({
    requiredBlinks: 2,
    onSuccess: () => console.log("Liveness passed!"),
    onError: (err) => console.error(err.code, err.message),
    faceDetectionTimeout: 30_000,
  });

  if (error) {
    return (
      <div>
        <p>{error.message}</p>
        {error.code === LivenessErrorCode.PERMISSION_DENIED && (
          <p>Please allow camera access.</p>
        )}
        <button type="button" onClick={retry}>Try again</button>
      </div>
    );
  }

  return (
    <div style={{ position: "relative", display: "inline-block" }}>
      {!isReady && <p>Starting camera…</p>}
      <video ref={videoRef} autoPlay playsInline muted />
      {faceBoundingBox && (
        <div
          style={{
            position: "absolute",
            left: `${faceBoundingBox.x * 100}%`,
            top: `${faceBoundingBox.y * 100}%`,
            width: `${faceBoundingBox.width * 100}%`,
            height: `${faceBoundingBox.height * 100}%`,
            border: "2px solid lime",
            pointerEvents: "none",
          }}
        />
      )}
      {isReady && !isFaceDetected && <p>Position your face in the frame.</p>}
      <p>Blinks: {blinkCount} {passed && "— Passed!"}</p>
    </div>
  );
}

API

useLiveness(options?)

Options

| Option | Type | Default | Description | |--------|------|--------|-------------| | requiredBlinks | number | 2 | Number of blinks required to pass. | | onSuccess | () => void | — | Called once when liveness passes. | | onError | (error: LivenessError) => void | — | Called when an error occurs. | | locateFile | (file: string) => string | jsDelivr CDN | URL for MediaPipe model files. | | camera | { width?, height?, facingMode? } | 640×480, user | Camera constraints. | | faceMesh | { maxNumFaces?, minDetectionConfidence?, minTrackingConfidence? } | — | FaceMesh model options. | | faceDetectionTimeout | number | 0 (off) | Timeout in ms before FACE_NOT_DETECTED if no face is seen. |

Return

| Property | Type | Description | |----------|------|-------------| | videoRef | RefObject<HTMLVideoElement \| null> | Attach to a <video> element. | | blinkCount | number | Current number of detected blinks. | | passed | boolean | true when required blinks are reached. | | error | LivenessError \| null | Current error (code + message). | | isReady | boolean | Camera has started. | | isFaceDetected | boolean | A face is currently in frame. | | faceBoundingBox | FaceBoundingBox \| null | Normalized face box (0–1) for overlay; null when no face. | | retry | () => void | Clear error and restart (e.g. after permission grant). |

Error codes (LivenessErrorCode)

| Code | Meaning | |------|--------| | ABORTED | Camera request was aborted (e.g. user navigated away). | | CAMERA_IN_USE | Camera is in use by another app or tab (NotReadableError). | | CAMERA_NOT_FOUND | No camera device found. | | FACE_NOT_DETECTED | No face seen within faceDetectionTimeout. | | MODEL_LOAD_FAILED | MediaPipe model failed to load (network, CDN, or WASM). | | MULTIPLE_FACES | More than one face in frame; process stops, use retry() to try again. | | NOT_ALLOWED | Camera not supported (e.g. non-HTTPS, no mediaDevices, insecure context). | | OVERCONSTRAINED | Requested camera constraints (e.g. resolution, facingMode) not supported. | | PERMISSION_DENIED | User denied camera access. | | PLAY_FAILED | Video failed to play (e.g. autoplay policy; user may need to tap "Start"). | | UNKNOWN | Other errors. |

On MULTIPLE_FACES, FACE_NOT_DETECTED, MODEL_LOAD_FAILED, or PLAY_FAILED the process stops; call retry() to restart.

Publishing

  • Run pnpm run build before publishing (or rely on prepublishOnly).
  • Package ships only dist/ and README.md (files in package.json).
  • React is a peer dependency; consumers must install it.

License

MIT