6.3.12 • Published 29 days ago

react-native-qrcode-svg v6.3.12

Weekly downloads
35,703
License
MIT
Repository
github
Last release
29 days ago

Looking for maintainers

I'm not working on any React Native projects anymore. Feel free to take over this project if you feel good about it!

NPM circleci

react-native-qrcode-svg

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

Discussion: https://discord.gg/RvFM97v

Features

  • Easily render QR code images
  • Optionally embed a logotype
AndroidiOS

Installation

Install dependency packages

yarn add react-native-svg react-native-qrcode-svg

Or

npm i -S react-native-svg react-native-qrcode-svg

If you are using React Native 0.60.+ go to the folder your-project/ios and run pod install, and you're done.

If not, use one of the following method to link.

Link with react-native link

If you are using React Native <= 0.59.X, link the native project:

react-native link react-native-svg

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'String Value of the QR code. Can also accept an array of segments as defined in Manual mode. Ex. [{ data: 'ABCDEFG', mode: 'alphanumeric' }, { data: '0123456', mode: 'numeric' }, { data: 253,254,255, mode: 'byte' }]
color'black'Color of the QR code
backgroundColor'white'Color of the background
enableLinearGradientfalseenables or disables linear gradient
linearGradient'rgb(255,0,0)','rgb(0,255,255)'array of 2 rgb colors used to create the linear gradient
gradientDirection170,0,0,0the direction of the linear gradient
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
logoBorderRadius0the border-radius of logo image (Android is not supported)
quietZone0quiet zone around the qr in pixels (useful when saving image to gallery)
getRefnullGet SVG ref for further usage
ecl'M'Error correction level
onError(error)undefinedCallback fired when exception happened during the code generating process

Saving generated code to gallery

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

@neur0base/app-sdk@borderfreefinancial/revoshowtvui-test@borderfreefinancial/revotvvideocomponent-testairmodrevoshowuireact-native-womasoft@everything-registry/sub-chunk-2588taro-qrcodetaro-code-creatorwallet-apprn-vayvaysalmonwalletv2sayswitch-payment-sdkstorybook-componentsstorybook-compostablex-sdkseru-react-native-print-template@digitalfactory/react-native-componentssales-sync-mobileinso-motorbike-liabilityipanel-rnapp-ajb-corekelp-mobile-walletpoket-app-testmy-interface-packagephudao-componentsreact-native-doreact-native-cotterreact-native-template-marcusvbdareact-native-template-umbappsamplereact-native-sjzt-libraryreact-native-kash-cash-sdkquasiorevoshowui-teststatefullapicjslibrarysubwallet-react-native-uiui-amber@arcturis/one-ui@aztec-3/react-native-walletconnect@carlosdp/react-native-dapp@7-eleven-platform/component-kits@7-eleven/component-kits@deficonnect/react-native-dappzeninvest@final-ui/kit@gaozh1024/rn-libs@functionland/component-library@functionland/fx-components@infinitebrahmanuniverse/nolb-react-native-q@kqinfo/ui@logo-rn/logo-qr-code@muhammadz/elixir-react-native-components@nftearth/react-native@mcplabs/mcp-rn-showtime-template@metamask/sdk-ui@kancha/kancha-ui@kdevashish0007/sdk-ui@react-native-oh-tpl/react-native-qrcode-svg@onebasket/ticketing-ui-react-native@onebasket/fnb-ui-react-native@peersyst/react-native-components@snapbox/mapp-qrcode-generator@sntns/sdk-ui@selene-wallet/app@zalastax/nolb-react-native-q@communi/chat-ui-react-native@borderfreefinancial/revoshowtvui@borderfreefinancial/revoshowui@thirdweb-dev/react-native@wallet_framework/rn@walletconnect/react-native-dapp@womasoft/rn-libs@xcoobee/react-native-xcoobee-payment-sdk@yoronsoft/rn-libsaphricaappindiqueganheaws-cognito-react-native-uibitlabscenteridentity-expocoderzy260-rncomponent-kitseostokenexpo-solana-walletdu-track-orderfastpay-react-package
6.3.11

1 month ago

6.3.12

29 days ago

6.3.2

3 months ago

6.3.1

7 months ago

6.3.0

10 months ago

6.2.0

2 years ago

6.1.2

3 years ago

6.1.1

4 years ago

6.1.0

4 years ago

6.0.7

4 years ago

6.0.6

5 years ago

6.0.5

5 years ago

6.0.3

5 years ago

6.0.1

5 years ago

6.0.0

5 years ago

5.3.2

5 years ago

5.3.1

5 years ago

5.2.0

5 years ago

5.1.2

6 years ago

5.1.1

6 years ago

5.1.0

6 years ago

5.0.7

6 years ago

5.0.6

7 years ago

5.0.5

7 years ago

5.0.4

7 years ago

5.0.3

7 years ago

5.0.2

7 years ago

5.0.0

7 years ago

4.0.2

8 years ago

4.0.1

8 years ago

4.0.0

8 years ago

3.1.1

8 years ago

3.1.0

8 years ago

3.0.2

8 years ago

3.0.0

8 years ago

2.0.0

8 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago