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.
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.
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-svgwithoutreact-native-svg, your app will crash with a missing module error. The former has the latter as a peer dependency, not a direct one.
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.
react-native-svg supports the full breadth of static SVG features needed in mobile apps:
<Rect>, <Ellipse>, <Polygon>)<Path> with d attribute)<Text>, <TSpan>)<LinearGradient>, <RadialGradient>)<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"
/>
);
}
react-native-svg if:victory-native, which depends on it)react-native-qrcode-svg)react-native-qrcode-svg only if: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-svgis the standard approach.
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.
| Aspect | react-native-svg | react-native-qrcode-svg |
|---|---|---|
| Role | SVG rendering engine | QR code generator (built on SVG) |
| Standalone? | ✅ Yes | ❌ No — requires react-native-svg |
| Use Case | Any vector graphic | Only QR codes |
| Dependencies | None (native modules only) | react-native-svg + qr.js |
| Output Control | Full SVG spec access | Limited to QR styling props |
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.
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).
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.
A QR Code generator for React Native based on react-native-svg and javascript-qrcode.
Discussion: https://discord.gg/RvFM97v
| Android | iOS |
|---|---|
![]() | ![]() |
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.
react-native linkIf you are using React Native <= 0.59.X, link the native project:
react-native link react-native-svg
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)}
/>
);
}
| Name | Default | Description |
|---|---|---|
| size | 100 | Size 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 |
| enableLinearGradient | false | enables 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 |
| logo | null | Image source object. Ex. {uri: 'base64string'} or {require('pathToImage')} |
| logoSize | 20% of size | Size of the imprinted logo. Bigger logo = less error correction in QR code |
| logoBackgroundColor | backgroundColor | The logo gets a filled quadratic background with this color. Use 'transparent' if your logo already has its own backdrop. |
| logoMargin | 2 | logo's distance to its wrapper |
| logoBorderRadius | 0 | the border-radius of logo image (Android is not supported) |
| quietZone | 0 | quiet zone around the qr in pixels (useful when saving image to gallery) |
| getRef | null | Get SVG ref for further usage |
| ecl | 'M' | Error correction level |
| onError(error) | undefined | Callback fired when exception happened during the code generating process |
Note: Experimental only ( not tested on iOS) , uses getRef() and needs RNFS module
npm install --save react-native-fs
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)
})
})
}
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.
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:
Make sure your project has a metro.config.js file. If not, create one at the root of your project.
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.
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);