
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
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 95 weekly downloads. As such, react-qrcode-scanner popularity was classified as not popular.
We found that react-qrcode-scanner demonstrated a healthy version release cadence and project activity because the last version was released less than 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
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.