This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
React Native Camera Kit is a high-performance, cross-platform camera library for React Native applications (iOS and Android). It provides:
- Photo capture with high performance optimization
- Barcode/QR code scanning capabilities
- Camera preview support (including iOS simulator)
- Extensive camera control options (flash, focus, zoom, torch)
- Device orientation detection
This is a native library that uses React Native Codegen for cross-platform native module bindings.
The TypeScript codebase provides the React wrapper and type definitions:
- Entry point (
src/index.ts): Exports the Camera component, types, and Orientation constants - Camera component (
src/Camera.tsx): Platform-agnostic wrapper that lazy-loads platform-specific implementationssrc/Camera.ios.tsx: iOS-specific camera componentsrc/Camera.android.tsx: Android-specific camera component
- Types and props:
src/types.ts: Core type definitions (CameraType, CodeFormat, TorchMode, FlashMode, FocusMode, ZoomMode, ResizeMode, CameraApi, CaptureData)src/CameraProps.ts: Complete Camera component props interface (both platform-specific and shared)
- Native specs (
src/specs/):CameraNativeComponent.ts: React Native Codegen definition for the camera view component (NativeProps)NativeCameraKitModule.ts: TurboModule specification for native camera functions (capture, authorization)
Key Pattern: Optional numeric props are represented as -1 or undefined until React Native Fabric supports optional values. Both platform-specific implementations handle this conversion.
-
iOS (
ios/ReactNativeCameraKit/): Swift implementationRealCamera.swift/SimulatorCamera.swift: Core camera implementation (real and simulator)CameraManager.swift: Manages camera state and configurationPhotoCaptureDelegate.swift: Handles photo capture logicScannerInterfaceView.swift/ScannerFrameView.swift: Barcode scanning UIRatioOverlayView.swift: Aspect ratio guide overlay
-
Android (
android/src/main/java/com/rncamerakit/): Kotlin implementationCKCamera.kt: Main camera view componentQRCodeAnalyzer.kt: Barcode scanning using CameraX- Event classes in
events/: Handle camera callbacks (zoom, orientation, errors, etc.) - Platform-specific code split between
newarch/(React Native 0.73+, Fabric) andoldarch/(legacy)
# Build TypeScript to JavaScript (outputs to dist/)
yarn build
# Clean build artifacts
yarn clean
# Run both clean and build
yarn clean && yarn build# Run ESLint
yarn lint
# ESLint rules are configured in .eslintrc.js with:
# - Max line length: 120 characters
# - Required semicolons, proper indentation (2 spaces)
# - No console.log or debugger statements allowed
# - Strict import resolution checking# Run all tests
yarn test
# Run tests for a specific file
yarn test -- src/__tests__/index.test.tsx
# The project uses Jest with minimal test configuration
# Tests should be placed in __tests__ directories# Bootstrap the example app (installs dependencies and pods)
yarn bootstrap
# For Linux:
yarn bootstrap-linuxThe camera component uses React Native Codegen to auto-generate native binding code:
- Props are defined in
src/specs/CameraNativeComponent.ts(NativeProps interface) - Changes to props require running:
yarn codegen(generatesbuild/directory) - The codegen config is in
package.jsonundercodegenConfig
The library uses React Native's platform module for loading platform-specific implementations:
// In src/Camera.tsx
const Camera = lazy(() =>
Platform.OS === 'ios'
? import('./Camera.ios')
: import('./Camera.android'),
);Both implementations handle color props differently:
- Android: Uses
processColor()to convert color values - iOS: Passes colors as-is
React Native Codegen doesn't support optional numeric props, so:
- Numeric props default to
-1to indicate "undefined" - The native layer interprets
-1as "no value provided" - This affects:
zoom,maxZoom,scanThrottleDelay,resetFocusTimeout,shutterAnimationDuration
The project uses strict TypeScript (strict: true in tsconfig.json):
@ts-expect-errorcomments are used for Codegen type mismatches (see Camera.ios.tsx line 33)- Type definitions must be accurate between user-facing types and native specs
- All numeric types from Codegen props must be converted in both platform files
# Run Jest tests
yarn test
# Build TypeScript (validates code)
yarn build
# Test files follow Jest conventions and are excluded from build (tsconfig.json excludes *.test.tsx)# Standard npm release
yarn release
# Beta release
yarn release:beta
# Local testing (creates and opens tar.gz)
yarn release:localThe library is published to npm as react-native-camera-kit with the files array in package.json controlling what gets included in the published bundle.
- TypeScript: Strict mode enabled, targets ESNext, outputs to
dist/with declaration files - Package managers: Yarn 1.22.22 required (specified in package.json engines)
- Node: Requires Node.js >= 18
- React Native: Uses version 0.79.0, supports both legacy and new architecture (Fabric)
- Import resolution: ESLint is configured to recognize
.ios.tsx,.android.tsx, and.jsplatform variants
Last synchronized upstream commit: 8e5149a6e6d3902ae87dad50da0d06ec2c61d2b8 Upstream version: 17.0.1 Fork version: 17.0.3 Last sync date: 2026-01-17 Sync status: success
Key changes from upstream:
- Replaced
iOsSleepBeforeStarting(Int) withiOsDeferredStart(Bool) for iOS camera startup optimization - iOS 26+ deferred start support via
AVCaptureOutput.deferredStartEnabled - Improved stress test logging with elapsed time tracking
- Various iOS formatting and code organization improvements
Files synced (16 files):
- All iOS Swift files (CameraView.swift, RealCamera.swift, SimulatorCamera.swift, CameraProtocol.swift)
- CKCameraViewComponentView.mm (Objective-C++ bridge)
- TypeScript layer (Camera.ios.tsx, CameraProps.ts, CameraNativeComponent.ts)
- Example app improvements (App.tsx, BarcodeScreenExample.tsx)
- README.md with updated props documentation
All QR-only Android architecture preserved:
android/build.gradle- Usesimplementation 'com.github.limpbrains:qr:v0.0.3'android/src/main/java/com/rncamerakit/QRCodeAnalyzer.kt- UsesQRDecoder.decode()from limpbrains/qrandroid/src/main/java/com/rncamerakit/CodeFormat.kt- Simplified enum (no ML Kit conversions)android/src/main/java/com/rncamerakit/CKCamera.kt- String callbackonQRCodeDetected(String)
yarn build- PASSEDyarn lint- PASSEDyarn test- PASSED- No
google.mlkitreferences in android/ - VERIFIED limpbrains/qrdependency present - VERIFIEDQRDecoder.decode()preserved - VERIFIED