
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
react-code-scanner
Advanced tools
A react component to scan bar codes and qr codes, it uses the zbar.wasm library in a web worker
A react component to scan bar codes and qr codes, it uses the zbar.wasm library in a web worker.
This uses hooks, so needs React >= 16.8
## Install
npm i react-code-scanner
const [result, setResult] = useState('');
const [facingMode, setFacingMode] = useState('environment');
return (
<div className="App">
<h1>Code Scanner</h1>
<div>Result: {result}</div>
<div>
<button onClick={() => setResult('')}>reset</button>
</div>
<div>
<button
onClick={() =>
setFacingMode(facingMode === 'environment' ? 'user' : 'environment')
}
>
current camera: {facingMode} switch camera
</button>
</div>
<CodeScanner
onResult={res => setResult(res.map(({ value }) => value).join(', '))}
onError={setResult}
facingMode={facingMode}
/>
</div>
);
name | default | meaning |
---|---|---|
width | 400 | the width in px of the camera view |
height | 300 | the heigth in px of the camera view |
onResult | console.log | the callback that is invoked when a code is decoded |
onError | console.error | the callback that is invoked when an error occours |
maxVideoWidth | 640 | the width in px of the image taken from the camera and passed to the scanner |
maxVideoHeight | 640 | the width in px of the image taken from the camera and passed to the scanner |
facingMode | 'environment' | this prop is used by devices with a back and a front camera and takes 2 values: 'environment' to use the back camera and 'user' to use the front camera |
codeOverlayColor | '#00ff00' | the color of the code overlay that is dispalyed when a code is recognized |
codeIndexColor | '#ff0000' | the color of the progressivo code id that is dispalyed when a code is recognized |
mirrorUserImage | true | if true the component will mirror the image when using the front camera |
FAQs
A react component to scan bar codes and qr codes, it uses the zbar.wasm library in a web worker
The npm package react-code-scanner receives a total of 4 weekly downloads. As such, react-code-scanner popularity was classified as not popular.
We found that react-code-scanner demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.