react-native-qrcode-svg vs react-native-svg
Generating and Rendering SVG Graphics in React Native
react-native-qrcode-svgreact-native-svgSimilar Packages:

Generating and Rendering SVG Graphics in React Native

react-native-svg is a foundational library for rendering SVG elements (like paths, circles, text, etc.) in React Native applications. It provides a set of React components that map directly to SVG primitives and works across iOS, Android, and Web via React Native Web.

react-native-qrcode-svg is a specialized utility built on top of react-native-svg. It generates QR codes as SVG graphics by leveraging the underlying SVG rendering capabilities of react-native-svg. It does not render anything on its own — it depends entirely on react-native-svg being installed and linked correctly.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
react-native-qrcode-svg01,167958 kB574 months agoMIT
react-native-svg07,9713.75 MB22820 days agoMIT

react-native-svg vs react-native-qrcode-svg: Understanding the Relationship and Use Cases

At first glance, comparing react-native-svg and react-native-qrcode-svg might seem like comparing apples to oranges — and you’d be right. These packages serve fundamentally different roles in a React Native project. One is a graphics engine, the other is a specialized component that depends on that engine. Let’s clarify their responsibilities, dependencies, and when each belongs in your stack.

🧱 Core Purpose: Foundation vs Specialization

react-native-svg is the underlying renderer for SVG content in React Native. It implements SVG elements like <Svg>, <Path>, <Circle>, <Text>, and more as native React components. Without it, no SVG can be displayed in a React Native app (outside of WebView hacks).

// react-native-svg: Drawing a simple circle
import Svg, { Circle } from 'react-native-svg';

function MyIcon() {
  return (
    <Svg height="100" width="100">
      <Circle cx="50" cy="50" r="40" fill="blue" />
    </Svg>
  );
}

react-native-qrcode-svg, by contrast, is a QR code generator that outputs SVG markup using components from react-native-svg. It handles the math and encoding logic to turn a string into a grid of black-and-white squares — but it cannot render anything without react-native-svg installed.

// react-native-qrcode-svg: Generating a QR code
import QRCode from 'react-native-qrcode-svg';

function ShareCode() {
  return <QRCode value="https://example.com" size={200} />;
}

⚠️ Important: If you install react-native-qrcode-svg without react-native-svg, your app will crash with a missing module error. The former has the latter as a peer dependency, not a direct one.

🔌 Dependency Chain: Who Needs What?

  • react-native-svg stands alone. It requires native linking (or auto-linking in modern React Native) but has no JavaScript dependencies for basic usage.
  • react-native-qrcode-svg requires react-native-svg to be installed and properly configured. It also depends on qr.js (a pure-JS QR encoder) internally, but that’s bundled.

You cannot use react-native-qrcode-svg without react-native-svg. But you can absolutely use react-native-svg without ever touching react-native-qrcode-svg.

🖼️ Rendering Capabilities: General Graphics vs One-Off Utility

react-native-svg supports the full breadth of static SVG features needed in mobile apps:

  • Shapes (<Rect>, <Ellipse>, <Polygon>)
  • Paths (<Path> with d attribute)
  • Text (<Text>, <TSpan>)
  • Gradients (<LinearGradient>, <RadialGradient>)
  • Transforms and groups (<G>, transform prop)
// Complex SVG with gradients and text
import Svg, { Defs, LinearGradient, Stop, Rect, Text } from 'react-native-svg';

function FancyBanner() {
  return (
    <Svg height="60" width="200">
      <Defs>
        <LinearGradient id="grad" x1="0%" y1="0%" x2="100%" y2="0%">
          <Stop offset="0%" stopColor="red" />
          <Stop offset="100%" stopColor="blue" />
        </LinearGradient>
      </Defs>
      <Rect x="0" y="0" width="200" height="60" fill="url(#grad)" />
      <Text x="100" y="35" fill="white" textAnchor="middle">Hello</Text>
    </Svg>
  );
}

react-native-qrcode-svg only does one thing: turn a string into a QR code. It exposes props like size, color, backgroundColor, and logo, but under the hood, it’s just composing <Rect> and <Path> elements from react-native-svg.

// Custom-styled QR code
import QRCode from 'react-native-qrcode-svg';

function BrandedQR() {
  return (
    <QRCode
      value="https://myapp.com/ref/123"
      size={250}
      color="#2a9d8f"
      backgroundColor="#f4f1de"
    />
  );
}

🛠️ When to Install Which?

Install react-native-svg if:

  • You need to display any SVG asset (icons, illustrations, charts)
  • You’re building data visualizations (e.g., with victory-native, which depends on it)
  • You plan to use any library that renders vector graphics (including react-native-qrcode-svg)

Install react-native-qrcode-svg only if:

  • You specifically need to generate QR codes as SVG (not PNG)
  • You want resolution-independent QR codes that scale cleanly on all screen densities
  • You’re okay with adding a small extra layer on top of react-native-svg

💡 Alternative: If you don’t need SVG output, consider react-native-qrcode-generator (which uses <Canvas>) or generating QR codes on the backend as PNGs. But for crisp, scalable QR codes in-app, react-native-qrcode-svg + react-native-svg is the standard approach.

🔄 Maintenance and Compatibility

Both packages are actively maintained as of 2024 and support modern React Native versions (0.60+ with auto-linking). They work on iOS, Android, and — with proper configuration — React Native Web.

However, note that react-native-svg occasionally requires version alignment with React Native due to native module changes. Always check its documentation for compatibility notes after major React Native upgrades.

📊 Summary: Key Differences

Aspectreact-native-svgreact-native-qrcode-svg
RoleSVG rendering engineQR code generator (built on SVG)
Standalone?✅ Yes❌ No — requires react-native-svg
Use CaseAny vector graphicOnly QR codes
DependenciesNone (native modules only)react-native-svg + qr.js
Output ControlFull SVG spec accessLimited to QR styling props

💡 Final Guidance

Think of react-native-svg as the canvas, and react-native-qrcode-svg as a stencil you place on that canvas. You need the canvas first. If your app only ever draws QR codes, you’ll still install both — but understand that react-native-svg is doing the actual rendering work.

Never install react-native-qrcode-svg without verifying that react-native-svg is present and working. And if you’re already using react-native-svg for other graphics, adding react-native-qrcode-svg is a lightweight way to get QR functionality without leaving the SVG ecosystem.

How to Choose: react-native-qrcode-svg vs react-native-svg

  • react-native-qrcode-svg:

    Choose react-native-qrcode-svg only when you specifically need to generate QR codes as scalable vector graphics in a React Native app. It abstracts QR code generation logic but requires react-native-svg as a peer dependency. Do not use it if you don’t need QR codes or if you’re already using a different QR code solution (e.g., canvas-based).

  • react-native-svg:

    Choose react-native-svg whenever you need to render any kind of SVG content in React Native — custom icons, charts, illustrations, or as a base for libraries like react-native-qrcode-svg. It’s a low-level, general-purpose SVG renderer and is essential for any vector graphics work in React Native.

README for react-native-qrcode-svg

NPM

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
gradientDirection[170,0,0,0]the 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)
   		  })
   	})
  }

Development and testing

This library comes with an Example App. You can find it in the directory ./Example.
Use the app to easily test your changes to react-native-qrcode-svg and when developing new features.

Read more details in the dedicated README.

Dependencies

PeerDependencies

Dependencies

Integrating react-native-qrcode-svg with React Native versions below 0.75

This library works seamlessly with React Native versions 0.75 and above. However, if you're using an older version of React Native (below 0.75), you might need to apply a custom transformation to your project's metro.config.js file to ensure compatibility with the TextEncoder API.

Here's how to configure the transformer for both Expo and React Native projects:

Setting Up the Transformer:

Make sure your project has a metro.config.js file. If not, create one at the root of your project.

Expo Projects:

const { getDefaultConfig } = require("expo/metro-config");

module.exports = (() => {
  const config = getDefaultConfig(__dirname);

  const { transformer } = config;

  config.transformer = {
    ...transformer,
    babelTransformerPath: require.resolve("react-native-qrcode-svg/textEncodingTransformation")
  };

  return config;
})();

Merge the contents from your project's metro.config.js file with this config.

React Native Projects:

const { getDefaultConfig, mergeConfig } = require("@react-native/metro-config");

const defaultConfig = getDefaultConfig(__dirname);

const config = {
  transformer: {
    babelTransformerPath: require.resolve("react-native-qrcode-svg/textEncodingTransformation"),
  },
};

module.exports = mergeConfig(defaultConfig, config);