{"id":15635009,"url":"https://github.com/kybarg/react-qr-scanner","last_synced_at":"2025-05-07T09:45:44.769Z","repository":{"id":29555842,"uuid":"122035800","full_name":"kybarg/react-qr-scanner","owner":"kybarg","description":"React component for reading QR codes using PC web camera or mobile phone camera.","archived":false,"fork":false,"pushed_at":"2023-03-04T02:34:28.000Z","size":12245,"stargazers_count":129,"open_issues_count":22,"forks_count":40,"subscribers_count":3,"default_branch":"next","last_synced_at":"2025-04-27T17:40:19.164Z","etag":null,"topics":["camera","qr-code","qrcode","qrcode-reader","qrcode-scanner","react","reader","webcam"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kybarg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-19T08:30:06.000Z","updated_at":"2025-04-03T00:40:38.000Z","dependencies_parsed_at":"2024-10-23T03:24:03.766Z","dependency_job_id":null,"html_url":"https://github.com/kybarg/react-qr-scanner","commit_stats":{"total_commits":52,"total_committers":5,"mean_commits":10.4,"dds":0.07692307692307687,"last_synced_commit":"06438b62166ae6c2571cddfb2e667ff98b15b920"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kybarg%2Freact-qr-scanner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kybarg%2Freact-qr-scanner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kybarg%2Freact-qr-scanner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kybarg%2Freact-qr-scanner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kybarg","download_url":"https://codeload.github.com/kybarg/react-qr-scanner/tar.gz/refs/heads/next","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252854148,"owners_count":21814638,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["camera","qr-code","qrcode","qrcode-reader","qrcode-scanner","react","reader","webcam"],"created_at":"2024-10-03T10:59:59.250Z","updated_at":"2025-05-07T09:45:44.747Z","avatar_url":"https://github.com/kybarg.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm version](https://badge.fury.io/js/react-qr-scanner.svg)](https://badge.fury.io/js/react-qr-scanner)\n\n## Introduction\nA [React](https://facebook.github.io/react/) component for reading QR codes from the webcam. It uses the WebRTC standards for reading webcam data and [jsQR](https://github.com/cozmo/jsQR) is used for detecting QR codes in that data. To optimise the speed and experience, a web-worker is used to offload the heavy QR code algorithm on a separate process. The web worker is inlined and loaded on creation of the component.\nThanks to initial repo https://github.com/JodusNodus/react-qr-reader\n\n## Demo\n[kybarg.github.io/react-qr-scanner/](https://kybarg.github.io/react-qr-scanner/)\n\n## Known Issues\n- Due to browser implementations the camera can only be accessed over https or localhost.\n- Not compatible with macOS/iOS Safari. Use `legacyMode` to support these platforms.\n- In Firefox a prompt will be shown to the user asking which camera to use, so `facingMode` will not affect it.\n\n## Install\n`npm install --save react-qr-scanner`\n\n## Example\n\n```js\nimport React, { Component } from 'react'\nimport QrReader from 'react-qr-scanner'\n\nclass Test extends Component {\n  constructor(props){\n    super(props)\n    this.state = {\n      delay: 100,\n      result: 'No result',\n    }\n\n    this.handleScan = this.handleScan.bind(this)\n  }\n  handleScan(data){\n    this.setState({\n      result: data,\n    })\n  }\n  handleError(err){\n    console.error(err)\n  }\n  render(){\n    const previewStyle = {\n      height: 240,\n      width: 320,\n    }\n\n    return(\n      \u003cdiv\u003e\n        \u003cQrReader\n          delay={this.state.delay}\n          style={previewStyle}\n          onError={this.handleError}\n          onScan={this.handleScan}\n          /\u003e\n        \u003cp\u003e{this.state.result}\u003c/p\u003e\n      \u003c/div\u003e\n    )\n  }\n}\n```\n\n## Props\n\n**onScan**\n\nType: `function`, Required, Argument: `result`\n\nScan event handler. Called every scan with the decoded value or `null` if no QR code was found.\n\n**onError**\n\nType: `function`, Required, Argument: `error`\n\nFunction to call when an error occurs such as:\n- Not supported platform\n- The lack of available devices\n\n**onLoad**\n\nType: `function`, Optional\n\nCalled when the component is ready for use.\n\n**onImageLoad**\n\nType: `function`, Optional, Argument: React img onLoad event\n\nCalled when the image in legacyMode is loaded.\n\n**delay**\n\nType: `number`, Optional, Default: `500`\n\nThe delay between scans in milliseconds. To disable the interval pass in `false`.\n\n**facingMode**\n\nType: `string`, Optional\n\nSpecify which camera direction should be used (if available). Options: `front` and `rear`.\n\n**legacyMode**\n\nType: `boolean`, Optional, Default: `false`.\n\nIf the device does not allow camera access (e.g. IOS Browsers, Safari) you can enable legacyMode to allow the user to take a picture (On a mobile device) or use an existing one. To trigger the image dialog just call the method `openImageDialog` from the parent component. **Warning** You must call the method from a user action (eg. click event on some element).\n\n**maxImageSize**\n\nType: `number`, Optional, Default: `1500`.\n\nIf `legacyMode` is active then the image will be downscaled to the given value while keepings its aspect ratio. Allowing larger images will increase the accuracy but it will also slow down the processing time.\n\n**style**\n\nType: `object`, Optional\n\nStyling for the preview element. This will be a `video` or an `img` when `legacymode` is `true`. **Warning** The preview will keep its aspect ratio, to disable this set the CSS property [objectFit](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit) to `fill`.\n\n**className**\n\nType: `string`, Optional\n\nClassName for the container element.\n\n**chooseDeviceId**\n\nType: `function`, Optional, Arguments: (1) video devices matching `facingMode`, (2) all video devices\n\nCalled when choosing which device to use for scanning. By default chooses the first video device matching `facingMode`, if no devices match the first video device found is choosen.\n\n**initialStream**\n\nType: `MediaStream`, Optional\n\nExisting MediaStream to use initially.\n\n## Dev\n\n### Install dependencies\n`npm install`\n\n### Build\n`npm run build`\n\n### Demo\n`npm run storybook`\n\n### Test\n`npm test`\n\n### Linting\n`npm run lint`\n\n## Tested platforms\n- Chrome 56 and Firefox 53 on macOs 10.12\n- Chrome 55 and Firefox 50 on Android 6.0.1\n\n## License\nThe MIT License (MIT)\n\nCopyright (c) 2017 Thomas Billiet\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkybarg%2Freact-qr-scanner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkybarg%2Freact-qr-scanner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkybarg%2Freact-qr-scanner/lists"}