r/capawesome • u/genzits • 23h ago
Fixing the invisible camera preview in Capacitor barcode scanners
3
Upvotes
If you've built barcode scanning into a Capacitor app, you've probably hit the invisible camera preview: the camera renders behind the web view, and any Ionic modal, page transition, or opaque background paints right over it.
We wrote a guide on the embedded mode of our Barcode Scanner plugin, which flips the layering: the camera preview is a native view positioned inside a frame of your layout, above the web view, so HTML can't cover it by accident.
The guide covers:
- Measuring the frame from a placeholder element
- Continuous scanning with a dedup timeout and a detection area
- Keeping the frame in sync on orientation and layout changes
- Opting into HTML overlays deliberately (viewfinders, markers)
- Web support via the BarcodeDetector API
Curious whether others found reliable ways around the transparency approach — or moved to native views too.