
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
react-qrcode-scanner
Advanced tools
A React component that provides a simple and efficient way to read QR codes from a web or mobile camera. This lightweight component utilizes HTML canvas to capture images and leverages the jsQR library to detect QR codes within the image data. NOTE: HTTPS is required to use camera on mobile devices. However, you can test over localhost on your computer
npm i react-qrcode-scanner
import React from 'react';
import { QrScanner } from 'react-qrcode-scanner';
function App() {
const handleScan = (value) => {
console.log({ value });
};
const handleError = (error) => {
console.log({ error });
};
return (
<div className='App'>
<QrScanner onScan={handleScan} onError={handleError} />
</div>
);
}
export default App;
| Prop Name | Type | Default Value | Description |
|---|---|---|---|
| onError | Function | (error) => console.log({error}) | Callback function that is called when an error occurs during scanning. |
| onScan | Function | (value) => console.log({value}) | Callback function that is called when a QR code is successfully scanned. |
| facingMode | String | 'environment' | The facing mode of the camera. Can be set to 'environment' or 'face'. |
| constraints | Object | null | The device constraints for the camera. |
| onLoad | Function | (val: {mirrorVideo, streamLabel}) => null | Callback function that is called when the component is loaded. |
| flipHorizontally | Boolean | false | Determines whether the video output should be flipped or reflected based on the facing mode. |
| style | Object | null | Additional styling for the section. |
| className | String | null | Additional class names for the section wrapper. |
| delay | Number | 800 | The delay between each scan attempt in milliseconds. |
| resolution | Number | 600 | The resolution of the canvas in pixels. |
| aspectRatio | string | '16:9' | Aspect ratio of the video frame. Default is landscape. Change to '3:4' for portrait |
| showViewFinder | Boolean | true | Determines whether to show the viewfinder. |
| viewFinder | Object | { border: '12px solid rgba(255,255,255,0.3)', position: 'absolute', borderRadius: '5px', width: '250px', height: '250px' } | Additional CSS styles for the viewfinder element. |
This project is licensed under the MIT License.
FAQs
QR code scanner component for React apps
The npm package react-qrcode-scanner receives a total of 64 weekly downloads. As such, react-qrcode-scanner popularity was classified as not popular.
We found that react-qrcode-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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.