← Back to Projects

rn-mrz-scanner

Native full-screen camera scanner to read MRZ from passports and ID cards. Uses Apple Vision on iOS and Google ML Kit on Android.

React NativeExpoMRZOCRCamera

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.

Features

  • TD-1 (ID cards — 3×30 chars) and TD-3 (passports — 2×44 chars) support
  • Apple Vision on iOS, Google ML Kit on Android
  • StringTracker for stable results across multiple frames
  • Expo Config Plugin for automatic permission setup
  • Full-screen native camera view

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

Installation

npx expo install rn-mrz-scanner

Usage

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

const handleScan = async () => {
  try {
    const mrz = await scanMRZ();
    console.log("MRZ result:", mrz);
  } catch (error) {
    if (error.code === "ERR_CANCELLED") {
      console.log("User cancelled the scan");
    }
  }
};

Requirements

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

License

MIT