Releases: sumitsahoo/detect-primary-camera
Releases · sumitsahoo/detect-primary-camera
v1.0.1
🎉 Detect Primary Camera v1.0.1 — Initial Release
A zero-dependency library to robustly detect the primary rear camera on mobile devices using the WebRTC enumerateDevices API.
Features
- Smart Camera Scoring — Ranks all available video devices using a scoring algorithm that considers label keywords, device index, and capabilities to find the best rear camera.
- Modern Device Support — Explicitly penalizes ultra-wide, telephoto, and macro lenses that are poor choices for barcode scanning, exam proctoring, and general use.
- Cross-Platform — Handles iOS ("Back Camera") and Android ("camera 0") naming quirks seamlessly.
- Framework Agnostic — Works in Vanilla JS/TS with a dedicated
usePrimaryCameraReact hook available viadetect-primary-camera/react. - LocalStorage Caching —
getAndSetBestRearCamera()persists the discovered device ID, speeding up subsequent loads. - SSR Safe — Gracefully handles server-side rendering environments.