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-ocr-capture

v0.2.0

Published

A React component that captures a camera frame and runs on-device OCR with PaddleOCR

Readme

react-ocr-capture

A React component that opens the device camera, lets the user capture a frame, and runs on-device OCR over it using PaddleOCR (browser/WASM, no server round-trip).

Install

npm install react-ocr-capture

react (>=18) is a peer dependency and is not bundled.

Usage

import { Ocr } from "react-ocr-capture";

function App() {
  return (
    <div style={{ height: 480 }}>
      <Ocr
        lang="en"
        ocrVersion="PP-OCRv5"
        ortOptions={{ backend: "wasm", wasmPaths: "/ort/" }}
        onReady={() => console.log("OCR ready")}
        onScore={(score) => console.log("Accuracy:", score)}
        onProcessingChange={(processing) => console.log("Processing:", processing)}
        onError={(error) => console.error("OCR error:", error)}
        onChange={(texts) => console.log("Recognized:", texts)}
      />
    </div>
  );
}

Preload and reuse the OCR engine

Model download and ONNX session creation are expensive. Preload once, then use the same engineCacheKey on the component so modal unmounts do not recreate the engine:

import { Ocr, preloadOcr, disposeOcrEngine } from "react-ocr-capture";

const engineOptions = {
  lang: "en",
  ocrVersion: "PP-OCRv5",
  ortOptions: { backend: "wasm", wasmPaths: "/ort/" },
};

await preloadOcr(engineOptions, "module-scanner");

<Ocr
  lang="en"
  ocrVersion="PP-OCRv5"
  ortOptions={engineOptions.ortOptions}
  engineCacheKey="module-scanner"
/>

// Release the cached model when the application no longer needs it.
await disposeOcrEngine("module-scanner");

Use one cache key per unique engine configuration. Reusing a key with different options returns the engine already stored under that key.

Select smaller or custom models

ocrOptions forwards additional PaddleOCR.create options. For example:

<Ocr
  engineCacheKey="module-scanner-tiny"
  ortOptions={{ backend: "wasm", wasmPaths: "/ort/" }}
  ocrOptions={{
    textDetectionModelName: "PP-OCRv6_tiny_det",
    textRecognitionModelName: "PP-OCRv6_tiny_rec",
  }}
/>

Props

| Prop | Type | Default | Description | | --- | --- | --- | --- | | lang | string | "en" | OCR language model to load | | ocrVersion | string | "PP-OCRv5" | PaddleOCR model version | | ortOptions | OrtOptions | { backend: "auto" } | ONNX Runtime backend and WASM configuration | | ocrOptions | PaddleOCRCreateOptions excluding the options above | – | Additional PaddleOCR options, including explicit model names/assets and worker mode | | engineCacheKey | string | – | Reuse a preloaded or previously created OCR engine across component mounts | | onReady | () => void | – | Called after OCR model initialization | | onError | (error: unknown) => void | – | Called when camera setup, OCR initialization, or recognition fails | | onScore | (score: number) => void | – | Called with average recognition confidence from 0 to 100 | | onProcessingChange | (processing: boolean) => void | – | Called when recognition starts or finishes | | onChange | (texts: string[]) => boolean \| void \| Promise<boolean \| void> | – | Called with recognized lines. Return false to discard capture and resume camera | | children | ReactNode | – | Rendered below camera view |

The component requires camera permission (getUserMedia) and must be served over HTTPS (or localhost) to work in most browsers.

Notes

  • Styling uses Tailwind utility classes. Tailwind consumers must include the package dist files in their content scan; other setups must provide equivalent utility styles.
  • react-icons is used for the capture/delete button icons.

Build

npm install
npm run build

Outputs ESM, CJS, and type declarations to dist/.