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-native-nitro-vision-kit

v0.4.0

Published

Subject segmentation, image classification, and on-device OCR for React Native. Vision on iOS, ML Kit on Android. Built with Nitro Modules.

Readme


Features

  • Cutouts — Isolate the subject (removeBackground). Trim, export PNG/JPEG, optional mask.
  • Labels — Ranked classifications (classifyImage). Offline on both platforms.
  • OCR — Read text (readText). Latin / CJK / Devanagari on Android; Vision on iOS 18+.
  • Compose — One decode, many results (analyzeImage). Segment + classify + OCR together.
  • Native — Nitro HybridObjects keep large results on the native side. Call dispose() when done.

Install

npm install react-native-nitro-vision-kit react-native-nitro-modules
cd ios && pod install

| | Minimum | | --- | --- | | React Native | 0.75 | | react-native-nitro-modules | 0.36.0 | | iOS | 13 · cutouts 17+ · OCR 18+ | | Android | API 24 |

Prefer the New Architecture — Nitro is built for it.


Quick start

import { VisionKit } from 'react-native-nitro-vision-kit'

Cutout

if (!VisionKit.capabilities.supportsBackgroundRemoval) {
  throw new Error(VisionKit.capabilities.backgroundRemovalUnavailableReason)
}

const cutout = await VisionKit.removeBackground(imagePath, { trim: true })
const path = await cutout.saveToTemporaryFile('png', 100)
cutout.dispose()

Labels

const labels = await VisionKit.classifyImage(imagePath, {
  maxResults: 5,
  minConfidence: 0.5,
})

OCR

const ocr = await VisionKit.readText(imagePath)
console.log(ocr.text)
ocr.dispose()

Compose (one decode)

const result = await VisionKit.analyzeImage(imagePath, {
  removeBackground: { trim: true },
  classify: { maxResults: 5 },
  readText: {},
})

result.segmentation?.dispose()
result.text?.dispose()

[!NOTE] removeBackground and readText return HybridObjects. Export or read what you need, then call dispose().


API

Capabilities

VisionKit.capabilities

| Field | Meaning | | --- | --- | | supportsBackgroundRemoval | Cutouts available | | backgroundRemovalUnavailableReason | Why cutouts are off | | supportsImageClassification | Labels available | | supportsTextRecognition | OCR available | | supportedTextLanguages | Language tags you can request |

removeBackground(path, options?)

Returns a cutout HybridObject.

| Platform | Requirement | | --- | --- | | iOS | 17+ | | Android | API 24+, Play Services, ML Kit subject segmentation (beta) |

Export: saveToTemporaryFile(format, quality) · toArrayBuffer() · toMaskBuffer()

| Option | Default | Meaning | | --- | --- | --- | | trim | true | Crop to the subject | | maxPixels | 6_000_000 | Cap when loading the image | | retainMask | false | Keep mask for toMaskBuffer() |

Result: width, height, bounds (VisionRect, 0–1), pixelBounds, foregroundCoverage, centroid, instanceCount, hasMask, sourceWidth, sourceHeight, trimOrigin

classifyImage(path, options?)

Returns { label, confidence, index }[], highest confidence first.

| Platform | Notes | | --- | --- | | iOS | 13+ | | Android | Model ships with the library — offline |

| Option | Default | Meaning | | --- | --- | --- | | maxResults | 0 | 0 keeps all above the score floor | | minConfidence | 0.5 | Lowest score to keep | | region | full image | VisionRect (0–1) |

readText(path, options?)

Returns a text HybridObject. Prefer text and blockAt(i)blocks copies everything into JS.

| Platform | Notes | | --- | --- | | iOS | 18+ (RecognizeTextRequest) | | Android | Play Services: Latin, Chinese, Japanese, Korean, Devanagari |

Image load cap: 4M pixels (both platforms). On Android, longest side is also capped at 2048.

| Option | Default | Platform | | --- | --- | --- | | languages | auto / Latin | Both | | recognitionLevel | accurate | iOS | | region | full image | Both (VisionRect) | | minTextHeightFraction | unset | Both | | usesLanguageCorrection | true | iOS | | customWords | unset | iOS | | maxCandidates | 1 | iOS (110) |

Android: languages selects script models. Non-Latin models also read Latin. Multiple non-Latin scripts can run together. A block may contain many lines.

iOS: Each block is one line.

analyzeImage(path, options)

One decode. Pass at least one of removeBackground, classify, or readText.

  • No subject found → segmentation is omitted; labels and text still run
  • If classify/OCR omit region and a cutout ran → subject bounds are used

Platform notes

Model download (Android)

| Method | First use | | --- | --- | | classifyImage | Offline — model is packaged | | removeBackground / readText | Downloads a Play Services model once |

Online: wait up to ~2 minutes for the first download, then offline. Offline with no model → fails immediately. iOS models ship with the system — no download step.

Paths

| Input | iOS | Android | | --- | --- | --- | | Absolute path | yes | yes | | file:// | yes | yes | | content:// | no | yes |

[!IMPORTANT] Only pass paths created by your app. Native code opens the path and returns pixels/text to JavaScript.


Example app

cd example
npm install
cd ios && bundle install && bundle exec pod install && cd ..
npm run ios    # or: npm run android

After a cutout, Keep saves to Photos.


License

MIT · Security · Changelog