React NativeExamples · Props · Code

Expo QR Code

To generate a QR code in an Expo or React Native app, use react-native-qrcode-svg (it renders via react-native-svg). Here’s a basic code, a branded one with a center logo, and the gotchas.

Install

Install both packages with Expo so the native SVG dependency is version-matched:

npx expo install react-native-qrcode-svg react-native-svg

Basic QR code

Pass a string to value and a pixel size:

// npx expo install react-native-qrcode-svg react-native-svg
import QRCode from 'react-native-qrcode-svg';
import { View } from 'react-native';

function MyQR() {
  return (
    <View style={{ padding: 24, alignItems: 'center' }}>
      <QRCode
        value="https://www.shipnative.dev"
        size={200}
        backgroundColor="#ffffff"
        color="#000000"
      />
    </View>
  );
}

QR code with a center logo

Add a logo image and give it a background so scanners still read it:

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

function BrandedQR() {
  return (
    <QRCode
      value="https://example.com/invite/abc123"
      size={220}
      logo={require('./assets/logo.png')}   // center logo
      logoSize={48}
      logoBackgroundColor="#ffffff"
      logoBorderRadius={8}
    />
  );
}

Props

PropTypeDefaultDescription
valuestringThe URL or text to encode. Required.
sizenumber100Width/height in pixels.
colorstring'black'Foreground (dots) color.
backgroundColorstring'white'Background color — keep it light for contrast.
logosourcerequire('...') image drawn in the center.
logoSizenumber20%Logo size in pixels.
getReffnRef to the SVG — use it to export the QR as an image.

Gotchas

  • You must install react-native-svgtoo — the QR library depends on it and won’t render without it.
  • Keep strong contrast (dark on light). A dark background or a big logo makes the code unscannable.
  • A logo larger than ~25% of the code covers too many modules and breaks scanning. Keep logoSize small.
  • To save/share the QR as a PNG, use getRef + toDataURL— you can’t screenshot an SVG reliably across platforms.

FAQ

How do I generate a QR code in Expo? Install react-native-qrcode-svg + react-native-svg, then render <QRCode value=... size=... />.

How do I add a logo? Pass a logo source and a small logoSize with a white background.

Related components

Skip the boilerplate

Describe your screen in ShipNative and it wires up the component for you — in a real, exportable React Native app.

Generate it with AI →