Socket
Socket
Sign inDemoInstall

react-native-qrcode-svg

Package Overview
Dependencies
2
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-qrcode-svg


Version published
Weekly downloads
112K
increased by2.36%
Maintainers
1
Install size
1.78 MB
Created
Weekly downloads
 

Package description

What is react-native-qrcode-svg?

The react-native-qrcode-svg package is a React Native component for generating QR codes. It allows you to create QR codes with various customization options, including size, color, and embedded logos or images.

What are react-native-qrcode-svg's main functionalities?

Basic QR Code Generation

This feature allows you to generate a basic QR code with a given value. The value can be any string, such as a URL, text, or other data.

import QRCode from 'react-native-qrcode-svg';

const BasicQRCode = () => (
  <QRCode
    value="https://example.com"
  />
);

Customizable QR Code

This feature allows you to customize the QR code's size, color, and background color. You can adjust these properties to fit the design requirements of your application.

import QRCode from 'react-native-qrcode-svg';

const CustomQRCode = () => (
  <QRCode
    value="https://example.com"
    size={200}
    color="blue"
    backgroundColor="yellow"
  />
);

QR Code with Logo

This feature allows you to embed a logo or image in the center of the QR code. This is useful for branding purposes or to provide additional context within the QR code.

import QRCode from 'react-native-qrcode-svg';
import { Image } from 'react-native';

const LogoQRCode = () => (
  <QRCode
    value="https://example.com"
    logo={{ uri: 'https://example.com/logo.png' }}
    logoSize={30}
    logoBackgroundColor="transparent"
  />
);

Other packages similar to react-native-qrcode-svg

Readme

Source

NPM circleci

react-native-qrcode-svg

A QR Code generator for React Native based on react-native-svg and javascript-qrcode.

Features

  • Easily render QR code images
  • Optionally embed a logotype

Installation

Please install react-native-svg first.

npm install react-native-svg --save
react-native link react-native-svg
npm install react-native-qrcode-svg --save

Examples

import QRCode from 'react-native-qrcode-svg';

//Simple usage, defaults for all but the value
render() {
  return (
    <QRCode
      value="http://awesome.link.qr"
    />
  );
};

// 30px logo from base64 string with transparent background
render() {
  let base64Logo = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAA..';
  return (
    <QRCode
      value="Just some string value"
      logo={{uri: base64Logo}
      logoSize={30}
      logoBackgroundColor='transparent'
    />
  );
};

// 20% (default) sized logo from local file string with white logo backdrop
render() {
  let logoFromFile = require('../assets/logo.png');
  return (
    <QRCode
      value="Just some string value"
      logo={logoFromFile}
    />
  );
};

// get base64 string encode of the qrcode (currently logo is not included)
getDataURL() {
  this.svg.toDataURL(this.callback);
}
callback(dataURL) {
  console.log(dataURL);
}
render() {
  return (
    <QRCode
      value="Just some string value"
      getRef={(c) => (this.svg = c)}
    />
  );
}

Props

NameDefaultDescription
size100Size of rendered image in pixels
value'this is a QR code'Value of the QR code
color'black'Color of the QR code
logonullImage source object. Ex. {uri: 'base64string'} or {require('pathToImage')}
logoSize20% of sizeSize of the imprinted logo. Bigger logo = less error correction in QR code
logoBackgroundColorbackgroundColorThe logo gets a filled quadratic background with this color. Use 'transparent' if your logo already has its own backdrop.
logoMargin2logo's distance to its wrapper
logoBorderRadiusnullthe border-radius of logo image (Android is not supported)
getRefnullGet SVG ref for further usage
ecl'M'Error correction level

Note: Experimental only ( not tested on iOS) , uses getRef() and needs RNFS module

npm install --save react-native-fs

Example for Android:

import { CameraRoll , ToastAndroid } from "react-native"
import RNFS from "react-native-fs"
...

  saveQrToDisk() {
   	this.svg.toDataURL((data) => {
   		RNFS.writeFile(RNFS.CachesDirectoryPath+"/some-name.png", data, 'base64')
   		  .then((success) => {
   			  return CameraRoll.saveToCameraRoll(RNFS.CachesDirectoryPath+"/some-name.png", 'photo')
   		  })
   		  .then(() => {
   			  this.setState({ busy: false, imageSaved: true  })
   			  ToastAndroid.show('Saved to gallery !!', ToastAndroid.SHORT)
   		  })
   	})
  }

Dependencies

PeerDependencies

Dependencies

Keywords

FAQs

Last updated on 05 Oct 2017

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc