Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

qr-scanner-react

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qr-scanner-react

An improved QR code scanner for React.

  • 2.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

qr-scanner-react

Install

npm install --save qr-scanner-react

Usage

Without props

<QrScanner />

With props

<QrScanner {...props} />

Props

Type

{
  viewFinderConfig: ViewFinderConfig | undefined;
  onResult: ResultHandler | undefined;
  onError: ErrorHandler | undefined;
  styles: QrScannerStyles | undefined;
  scanConfig: ScanConfig | undefined;
  'full-width': boolean | undefined;
}
PropDescription
viewFinderConfigConfigure the appearance of the viewFinder.
onResultCalled when a QR code is read.
onErrorCalled when an error occurred or a QR Code cannot be read.
stylesConfigure the CSS of the rendered elements.
scanConfigConfigure the scanning behavior.
full-widthA boolean describing whether the camera should be cropped to square, or not. By default, full-width is false, and so it is cropped to a square.

viewFinderConfig

An object used to configure the appearance of the view finder.

Type

{
  visible: boolean | undefined;
  outerColor: string | undefined;
  strokeWidth: string | undefined;
  strokeColor: string | undefined;
  radius: string | undefined;
  strokeLength: string | undefined;
  custom: React.ReactElement<undefined> | undefined;
}

Explanation

AttributeDescriptionDefaultExamples
visibleWhether the view finder should be visible.falsevisible : true
outerColorBackground color outside the scanning region.#00000000outerColor: "black" outerColor: "#FFFFFFAA",
strokeWidthWidth of the lines constituting the view finder.3pxstrokeWidth: "10px" strokeWidth: "1.2em"
strokeColorColor of the lines constituting the view finder.#000000strokeColor: "black" strokeColor: "#FFFFFFAA"
radiusRadius of the corners of the view finder.5pxradius: "10px" radius: "1.2em" radius: "15%"
strokeLengthLength of the lines constituting the view finder.40pxstrokeLength: "100px" strokeLength: "1.2em" strokeLength: "55%"
customInstead of using the built-in view finder with the customizations, you can provide your own, in which case, your view finder will be used.undefinedcustom : <CustomViewFinder />

onResult

A function called when a QR code is read.

Type

(result: ScanResult) => void

ScanResult

{
  data: string;
  cornerPoints: ({ x: number; y: number; }[]);
}
AttributeDescription
dataThe data read from the QR code.
cornerPointsThe location of the corners of the QR code scanned.

Default

(result) => {
  console.log(result);
};

onError

A function called when an error occurred or a QR Code cannot be read.

Type

(error: Error | string) => void;

Default

(error) => {
  console.log(error);
};

styles

An object used to configure the CSS of the rendered elements.

Type

{
  video: CSSProperties | undefined;
  videoContainer: CSSProperties | undefined;
  container: CSSProperties | undefined;
}

scanConfig

An object used to configure the scanning behavior.

Type

{
  qrColor: 'dark' | 'light' | 'both' | undefined;
  maxScansPerSecond: number | undefined;
  cameraPreference: 'environment' | 'user' | DeviceId: string | undefined;
}

Explanation

AttributeDescriptionDefault
qrColorThe colors of the QR codes that should be scanned."both"
maxScansPerSecondLimit the number of scans made a second.5
cameraPreferenceWhich camera should be used, if there are multiple camera options."environment"

License

MIT © jakub-ucinski

FAQs

Package last updated on 05 Aug 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc