react-native-nitro-barcode
v1.1.1
Published
High-performance CODE128 and QR Code generator via Nitro C++
Maintainers
Readme
react-native-nitro-barcode
Native CODE128 barcode rasterization for React Native, implemented in C++ via Nitro Modules.
Features
- CODE128 set B encoding (same symbology as
react-native-barcode-svg/ JsBarcode) - QR Code encoding (byte mode, error correction M, versions 1–40)
- Rasterizes to RGBA8888 on a background thread (C++)
- Zero SVG / JS barcode layout work at runtime
- Typed Nitro Hybrid Object API
Install
npm install react-native-nitro-barcode react-native-nitro-modulesor:
yarn add react-native-nitro-barcode react-native-nitro-modulesThen install iOS pods:
cd ios && pod installreact-native-nitro-modules is a required peer dependency. Images render with React Native Image; Skia is not required.
Usage
import {
getBarcodeGenerator,
NitroBarcodeImage,
NitroQrCode,
} from 'react-native-nitro-barcode';
const gen = getBarcodeGenerator();
const bitmap = gen.generateCode128('1234567890', {
moduleWidth: 2,
height: 60,
lineColor: 0xff000000,
backgroundColor: 0xffffffff,
});
// bitmap: { width, height, data: ArrayBuffer }
<NitroBarcodeImage
value={value}
options={{ moduleWidth: 2, height: 60, lineColor: 0xff000000 }}
/>;
const qr = gen.generateQr('https://example.com', {
moduleWidth: 4,
quietZoneModules: 4,
lineColor: 0xff000000,
backgroundColor: 0xffffffff,
});
<NitroQrCode value="https://example.com" size={100} />Regenerate Nitro bindings
After editing src/specs/*.nitro.ts, regenerate the Nitro bindings:
npx nitrogen
npm run build