react-webcam
DEMO: https://codepen.io/mozmorris/pen/JLZdoP
https://www.npmjs.com/package/react-webcam
Webcam component for React. See http://caniuse.com/#feat=stream for browser compatibility.
Note: Browsers will throw an error if the page is loaded from insecure origin. I.e. Use https.
Installation
# with npm
npm install react-webcam
# with yarn
yarn add react-webcam
Demo
https://codepen.io/mozmorris/pen/JLZdoP
Usage
import React from "react";
import Webcam from "react-webcam";
const WebcamComponent = () => <Webcam />;
Props
The props here are specific to this component but one can pass any prop to the underlying video tag eg className
, style
, muted
, etc
prop | type | default | notes |
---|---|---|---|
audio | boolean | false | enable/disable audio |
audioConstraints | object | MediaStreamConstraint(s) for the audio | |
disablePictureInPicture | boolean | false | disable Picture-in-Picture |
forceScreenshotSourceSize | boolean | false | uses size of underlying source video stream (and thus ignores other size related props) |
imageSmoothing | boolean | true | pixel smoothing of the screenshot taken |
mirrored | boolean | false | show camera preview and get the |