@meeeetup/camera-react-native
v0.9.0
Published
React Native SDK for meeeetup-cam — Vision Camera + native ML Kit frame processor
Readme
@meeeetup/camera-react-native
React Native face-capture SDK for the Meeeetup face-ID service. Face detection runs on the camera's worklet thread through a native Vision Camera frame processor (ML Kit), and the results feed the shared tracking and quality-selection pipeline.
BYOT (bring your own transport). The SDK makes no network request and
holds no credential: it calls onBatchCapture with base64 JPEG data URLs and
sending them is your code — any backend, any auth scheme, any retry strategy.
No pairing UI.
You own the <Camera> element and its ref; the hook owns the pipeline.
Install
pnpm add @meeeetup/camera-react-native
pnpm add react-native-vision-camera react-native-vision-camera-face-detector
pnpm add react-native-worklets-core react-native-fs@meeeetup/camera-core arrives as a dependency. For Expo, swap pnpm add for
npx expo install on the four native packages.
| Peer | Range | Why |
|---|---|---|
| react | ^18 \|\| ^19 | Hook host |
| react-native | >=0.73.0 | NativeModules / new-arch support |
| react-native-vision-camera | >=4.0.0 | <Camera>, useFrameProcessor, runAtTargetFps |
| react-native-vision-camera-face-detector | >=1.10.0 | Native ML Kit detector |
| react-native-worklets-core | >=1.5.0 | Worklet → JS hop |
| react-native-fs | >=2.20.0 | Reads the cached snapshot as base64 |
react-native-fs is not optional: without it the hook reports
"react-native-fs is required as a peer dependency" through error and never
caches a JPEG, so no face is ever committed.
Frame processors also need Vision Camera's worklets Babel plugin — follow
react-native-vision-camera's frame-processor setup for
react-native-worklets-core first.
Permissions: android.permission.CAMERA in AndroidManifest.xml,
NSCameraUsageDescription in Info.plist.
Usage
import { useRef } from "react";
import { useWindowDimensions } from "react-native";
import { Camera, useCameraDevice } from "react-native-vision-camera";
import { useFaceCaptureSession } from "@meeeetup/camera-react-native";
function CaptureScreen({ captureKey }: { captureKey: string }) {
const camera = useRef<Camera>(null);
const device = useCameraDevice("front");
const { width, height } = useWindowDimensions();
const { ready, error, trackedCount, frameProcessor } = useFaceCaptureSession({
cameraRef: camera,
sessionType: "passive",
// Preview size in px — makes the native detector emit window-space
// coordinates, so detections line up with the preview.
windowWidth: width,
windowHeight: height,
cameraFacing: "front",
onBatchCapture: async (faces) => {
const res = await fetch("https://api.example.com/capture", {
method: "POST",
headers: {
Authorization: `Bearer ${captureKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
images: faces.map((f) => ({
image: f.dataUrl,
capturedAt: new Date(f.createdAt).toISOString(),
})),
}),
});
// Throw to report failure. A missing status, <400 or >=500 is retried;
// 4xx drops that batch.
if (!res.ok) throw Object.assign(new Error("send failed"), { status: res.status });
},
});
if (!device) return null;
return (
<Camera
ref={camera}
device={device}
isActive
photo
frameProcessor={frameProcessor}
style={{ flex: 1 }}
/>
);
}photo must stay enabled: the hook falls back to takePhoto() on cameras that
do not expose takeSnapshot().
sessionType: "interactive" runs the same pipeline without the batch timer —
call flushBatch() yourself. Either way, a flush only hands over faces whose
track has settled for more than 5 s, so a still-improving track is never sent
early.
Transport
onBatchCapture is the only output path. Rejecting (throwing) from the sink
re-queues the batch; resolving marks it sent. There is no built-in HTTP
client — pick your own stack (fetch, Axios, native HTTP, OkHttp bridge,
whatever) and send the JPEG data URLs however your backend expects.
Exports
useFaceCaptureSession, RNFrameBuffer, facesToDetections,
FaceCaptureSession, plus the Detection, FrameBuffer, SelectedFace,
NoseLandmark, CameraLike, VisionCameraFace, UseFaceCaptureSessionOptions
and UseFaceCaptureSessionReturn types.
Licence
Proprietary — see LICENSE. Use requires a current agreement with MeeeetUp1120.
