{"id":13629872,"url":"https://github.com/ekreutz/react-native-barcode-scanner-google","last_synced_at":"2025-09-07T05:34:29.834Z","repository":{"id":97624870,"uuid":"64378453","full_name":"ekreutz/react-native-barcode-scanner-google","owner":"ekreutz","description":"Barcode scanner for react native, which implements barcode detection from Google's Vision API.","archived":false,"fork":false,"pushed_at":"2023-01-10T16:12:42.000Z","size":114,"stargazers_count":113,"open_issues_count":22,"forks_count":69,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-06-06T04:03:52.055Z","etag":null,"topics":["android","barcode-scanner","react-native","react-native-component","scanner"],"latest_commit_sha":null,"homepage":null,"language":"Java","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/ekreutz.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}},"created_at":"2016-07-28T08:36:16.000Z","updated_at":"2024-05-21T02:06:48.000Z","dependencies_parsed_at":"2023-03-14T13:15:45.196Z","dependency_job_id":null,"html_url":"https://github.com/ekreutz/react-native-barcode-scanner-google","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ekreutz/react-native-barcode-scanner-google","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekreutz%2Freact-native-barcode-scanner-google","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekreutz%2Freact-native-barcode-scanner-google/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekreutz%2Freact-native-barcode-scanner-google/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekreutz%2Freact-native-barcode-scanner-google/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ekreutz","download_url":"https://codeload.github.com/ekreutz/react-native-barcode-scanner-google/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekreutz%2Freact-native-barcode-scanner-google/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271579433,"owners_count":24784250,"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","status":"online","status_checked_at":"2025-08-22T02:00:08.480Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["android","barcode-scanner","react-native","react-native-component","scanner"],"created_at":"2024-08-01T22:01:22.407Z","updated_at":"2025-08-22T03:32:16.918Z","avatar_url":"https://github.com/ekreutz.png","language":"Java","funding_links":[],"categories":["Java"],"sub_categories":[],"readme":"# react-native-barcode-scanner-google\n\n___\n\n**Author's notes**\n\n1. This is *not* the exact version you install using `npm i react-native-barcode-scanner-google`. That version was uploaded based on this code, by a third party. Use at your own risk!\n\n2. As of September 2019, this repo is no longer being maintained. Due to its simplicitity it should still work great though so keep using it by all means!\n\n3. Look into https://github.com/react-native-community/react-native-camera for new projects if the bigger package/dependency tree isn't a problem. The latest version includes an implementation of Google's Vision API via this library. Enjoy!\n\n___\n\nVery fast barcode scanner view for React Native applications. Only for Android. Use something like `react-native-camera` for iOS.\nThe postfix `-google` is added since the native implementation is based on Google's Barcode API:\nhttps://developers.google.com/vision/barcodes-overview\n\nCompared to other barcode scanners for Android that don't rely on Google's Barcode API, this implementation should prove to be:\n\n* Faster\n* More accurate\n* More convenient (supports scanning in any direction)\n\nNote that this barcode scanner doesn't ship with a fancy overlay to display a scanning interface to the user. It's just a fast scanner view that shows the camera stream, ontop of which you can overlay your own UI.\n\n## Instructions\n\nTo include the latest version (1.3.0) `react-native-barcode-scanner-google` in your project, run the following terminal commands in your React Native project root folder:\n\n1.\n\n```\nnpm install git+https://github.com/ekreutz/react-native-barcode-scanner-google.git#v1.3.0 --save\n```\n\n2.\n\n```\nreact-native link react-native-barcode-scanner-google\n```\n\n## Simple usage example\n\nExample `index.android.js` of an app named BarcodeApp.\n\n```js\nimport React, { Component } from 'react';\nimport { AppRegistry, StyleSheet, Text, View, Alert } from 'react-native';\nimport BarcodeScanner from 'react-native-barcode-scanner-google';\n\nexport default class BarcodeApp extends Component {\n    render() {\n        return (\n            \u003cView style={{ flex: 1 }}\u003e\n                \u003cBarcodeScanner\n                    style={{ flex: 1 }}\n                    onBarcodeRead={({ data, type }) =\u003e {\n                        // handle your scanned barcodes here!\n                        // as an example, we show an alert:\n                        Alert.alert(\n                            `Barcode '${data}' of type '${type}' was scanned.`\n                        );\n                    }}\n                /\u003e\n            \u003c/View\u003e\n        );\n    }\n}\n\nAppRegistry.registerComponent('BarcodeApp', () =\u003e BarcodeApp);\n```\n\n## Advanced usage example (all properties used)\n\nNote: even though they're not used in this example, notice how we import the functions `pauseScanner` and `resumeScanner`. These can be used in complex UIs to start or stop the camera stream to the scanner. Read more about how they work in _Properties_ down below.\n\n```js\nimport React, { Component } from 'react';\nimport { AppRegistry, StyleSheet, Text, View, Alert } from 'react-native';\n\nimport BarcodeScanner, {\n    Exception,\n    FocusMode,\n    TorchMode,\n    CameraFillMode,\n    BarcodeType,\n    pauseScanner,\n    resumeScanner\n} from 'react-native-barcode-scanner-google';\n\nexport default class BarcodeApp extends Component {\n    render() {\n        return (\n            \u003cView style={{ flex: 1 }}\u003e\n                \u003cBarcodeScanner\n                    style={{ flex: 1 }}\n                    onBarcodeRead={({ data, type }) =\u003e {\n                        // handle your scanned barcodes here!\n                        // as an example, we show an alert:\n                        Alert.alert(\n                            `Barcode '${data}' of type '${type}' was scanned.`\n                        );\n                    }}\n                    onException={exceptionKey =\u003e {\n                        // check instructions on Github for a more detailed overview of these exceptions.\n                        switch (exceptionKey) {\n                            case Exception.NO_PLAY_SERVICES:\n                            // tell the user they need to update Google Play Services\n                            case Exception.LOW_STORAGE:\n                            // tell the user their device doesn't have enough storage to fit the barcode scanning magic\n                            case Exception.NOT_OPERATIONAL:\n                            // Google's barcode magic is being downloaded, but is not yet operational.\n                            default:\n                                break;\n                        }\n                    }}\n                    focusMode={FocusMode.AUTO /* could also be TAP or FIXED */}\n                    torchMode={TorchMode.ON /* could be the default OFF */}\n                    cameraFillMode={\n                        CameraFillMode.COVER /* could also be FIT */\n                    }\n                    barcodeType={\n                        BarcodeType.CODE_128 |\n                        BarcodeType.EAN_13 |\n                        BarcodeType.EAN_8 /* replace with ALL for all alternatives */\n                    }\n                /\u003e\n            \u003c/View\u003e\n        );\n    }\n}\n\nAppRegistry.registerComponent('BarcodeApp', () =\u003e BarcodeApp);\n```\n\n## Properties\n\n#### `barcodeTypes`\n\nBitmask of the different barcode formats you want to scan for.\nFor instance `BarcodeType.QR_CODE | BarcodeType.EAN_8 | BarcodeType.EAN_13` or just `BarcodeType.ALL` to search for all barcodes supported. Use `import { BarcodeType } from 'react-native-barcode-scanner-google';` to import the `BarcodeType` object.\n\nAll possible values are: (Bitwise OR can be used to select multiple formats)\n\n* `BarcodeType.ALL` (default)\n* `BarcodeType.CODE_128`\n* `BarcodeType.CODE_39`\n* `BarcodeType.CODE_93`\n* `BarcodeType.CODABAR`\n* `BarcodeType.DATA_MATRIX`\n* `BarcodeType.EAN_13`\n* `BarcodeType.EAN_8`\n* `BarcodeType.ITF`\n* `BarcodeType.QR_CODE`\n* `BarcodeType.UPC_A`\n* `BarcodeType.UPC_E`\n* `BarcodeType.PDF417`\n* `BarcodeType.AZTEC`\n\n---\n\n#### `focusMode`\n\nUse `import { FocusMode } from 'react-native-barcode-scanner-google';` to import the `FocusMode` object.\n\nPossible values for this prop are:\n\n* `FocusMode.AUTO`: Continuous automatic focus. (default)\n* `FocusMode.TAP`: Tap-to-focus\n* `FocusMode.FIXED`: Fixed focus\n\n---\n\n#### `torchMode`\n\nUse `import { TorchMode } from 'react-native-barcode-scanner-google';` to import the `TorchMode` object.\n\nPossible values for this prop are:\n\n* `TorchMode.OFF`: Disables flashlight. (default)\n* `TorchMode.ON`: Enables flashlight.\n\n---\n\n#### `cameraFillMode`\n\nUse `import { CameraFillMode } from 'react-native-barcode-scanner-google';` to import the `CameraFillMode` object.\n\nPossible values for this prop are:\n\n* `CameraFillMode.COVER`: Make the camera stream fill the entire view, possibly cropping out a little bit on some side. (default)\n* `CameraFillMode.FIT`: Make the camera stream fit snugly inside the view, possibly showing wide bars on some side.\n\n---\n\n#### `onBarcodeRead()`: function(obj: Object)\n\nAlias `onBarCodeRead()`. Callback function that will be called every time the scanner detects a new barcode.\nThe parameter `obj` has the shape:\n\n```js\n{\n    \"data\": \"12345678\", // the barcode itself\n    \"type\": \"EAN_13\" // the format of data. will be one of the supported formats, or \"UNKNOWN_FORMAT\"\n}\n```\n\n---\n\n#### `onException`: function(key: String)\n\nGoogle's Barcode API requires some native code to be downloaded to the device behind the scenes for it to work. This makes it possible to always keep the latest barcode scanner featurability available, but also comes with a few drawbacks. Namely, the barcode scanning features might not be available yet when the user opens the app to scan. This callback allows for those exceptions to be handled on the JS side.\nUse `import { Exception } from 'react-native-barcode-scanner-google';` to import the `Exception` object.\n\nPossible values for the parameter `key` are:\n\n* `Exception.NO_PLAY_SERVICES`: Occurs when the user doesn't have the latest version of Google Play Services. If this is the case, ask the user to update Play Services.\n* `Exception.LOW_STORAGE`: Occurs when the native setup couldn't be completed because the user's device had low storage.\n* `Exception.NOT_OPERATIONAL`: Occurs when the user did have enough storage, but opened the app before downloads were completed. Encourage the user to wait a bit or turn on their internet if this happens.\n\nIf any of the above events occur, the scanner will default to show a black screen instead of the camera preview.\n\n---\n\n#### Utility functions `resumeScanner` and `pauseScanner`: function()\n\nMethods that can be used to pause/resume the camera stream of the barcode scanner JS-side. Most often you will not need these at all! They're meant to give advanced users more control over the scanner view.\nUse `import { resumeScanner, pauseScanner } from 'react-native-barcode-scanner-google';` to import these utility functions.\n\nBoth methods return a `Promise` object and are used similarly. Example usage of `resumeScanner`:\n\n```js\nresumeScanner()\n    .then(() =\u003e {\n        // do something after the scanner (camera) stream was resumed.\n    })\n    .catch(e =\u003e {\n        // Print error if scanner stream could not be resumed.\n        console.log(e);\n    });\n```\n\n---\n\n## License\n\n[MIT License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fekreutz%2Freact-native-barcode-scanner-google","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fekreutz%2Freact-native-barcode-scanner-google","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fekreutz%2Freact-native-barcode-scanner-google/lists"}