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

rn-mrz-scanner

v2.0.3

Published

A React Native Expo module for scanning MRZ (Machine Readable Zone) from passports and ID cards using the device camera. Supports TD-1 (ID cards) and TD-3 (passports) formats.

Readme

rn-mrz-scanner

A React Native Expo module that opens a native full-screen camera scanner to read the MRZ (Machine Readable Zone) from passports and ID cards.

| Platform | OCR Engine | | -------- | --------------------------------- | | iOS | Apple Vision (VNRecognizeTextRequest) | | Android | Google ML Kit Text Recognition |

Supports TD-1 (ID cards — 3 × 30 chars) and TD-3 (passports — 2 × 44 chars).


Installation

npx expo install rn-mrz-scanner

or

npm install rn-mrz-scanner
# yarn add rn-mrz-scanner

Expo Config Plugin (managed workflow)

Add the plugin to your app.json / app.config.js:

{
  "expo": {
    "plugins": [
      [
        "rn-mrz-scanner",
        {
          "cameraPermissionText": "We need camera access to scan your document's MRZ."
        }
      ]
    ]
  }
}

Then rebuild:

npx expo prebuild --clean
npx expo run:ios   # or run:android

The plugin automatically adds NSCameraUsageDescription (iOS) and CAMERA permission (Android).


Usage

import { scanMRZ } from "rn-mrz-scanner";

export default function App() {
  const handleScan = async () => {
    try {
      const mrz = await scanMRZ();
      console.log("MRZ result:", mrz);
      // TD-3 example:
      // "P<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<<\nL898902C36UTO7408122F1204159ZE184226B<<<<<10"
    } catch (error) {
      if (error.code === "ERR_CANCELLED") {
        console.log("User cancelled the scan");
      }
    }
  };

  return <Button title="Scan MRZ" onPress={handleScan} />;
}

Return Value

scanMRZ() returns a Promise<string> containing the raw MRZ text. Lines are separated by \n.

  • TD-1 (ID card): 3 lines, each 30 characters
  • TD-3 (Passport): 2 lines, each 44 characters

You can parse the result with libraries like mrz.


API

scanMRZ(): Promise<string>

Opens a full-screen camera view that automatically detects and reads MRZ text.

Throws:

| Code | Description | | --- | --- | | ERR_CANCELLED | User dismissed the scanner | | ERR_NO_ACTIVITY | (Android) No activity available | | ERR_UI | (iOS) Could not present the scanner | | ERR_MRZ | (Android) MRZ could not be read |


Requirements

  • iOS: 15.0+
  • Android: API 21+ (CameraX)
  • Expo SDK: 49+

How It Works

  1. A native full-screen camera view is presented.
  2. Each frame is processed with OCR (Vision on iOS, ML Kit on Android).
  3. Detected text is filtered and matched against MRZ regex patterns.
  4. A StringTracker stabilises the result over multiple frames to avoid false positives.
  5. Once a stable MRZ is detected, the camera closes and the result is returned.

License

MIT