npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@vardrz/react-native-bluetooth-escpos-printer

v0.1.1

Published

Forked react-native-bluetooth-escpos-printer with additional print improvements and TypeScript support.

Downloads

247

Readme

React Native Bluetooth ESC/POS & TSC Printer

GitHub license npm version

React Native plugin for Bluetooth ESC/POS & TSC printers.

💡 Still under development.
✅ Currently supports Android, iOS support planned.

Any questions or bugs? Please open an issue.


🧩 Acknowledgments

This project is a continuation of the excellent work started by Janus J K Lu and later improved by Ccdilan. This fork by Farid Fatkhurrozak (Vardrz) builds upon Ccdilan’s version — adding TypeScript support, minor native fixes, and extra print options.

Special thanks to both Janus and Ccdilan — their contributions laid the foundation
for this version to exist and continue evolving.


📦 Installation

Install via NPM:

npm install @vardrz/react-native-bluetooth-escpos-printer --save

Or install via GitHub:

npm install https://github.com/vardrz/react-native-bluetooth-escpos-printer.git --save

🚀 Usage

Import module

import {
  BluetoothManager,
  BluetoothEscposPrinter,
  BluetoothTscPrinter
} from '@vardrz/react-native-bluetooth-escpos-printer';

🔧 BluetoothManager

Manages Bluetooth service: status check, enable/disable, scan, connect/unpair.

✅ isBluetoothEnabled

Check whether Bluetooth is enabled.

BluetoothManager.isBluetoothEnabled().then(enabled => {
  alert(enabled); // true / false
}, err => alert(err));

✅ enableBluetooth (Android only)

Enable Bluetooth service and return paired devices.

BluetoothManager.enableBluetooth().then(r => {
  const paired = r.map(item => JSON.parse(item));
  console.log('Paired devices:', paired);
});

✅ disableBluetooth (Android only)

Disable Bluetooth service.

BluetoothManager.disableBluetooth().then(() => {
  console.log('Bluetooth disabled');
});

✅ scanDevices

Scans nearby devices and returns paired/found results.

BluetoothManager.scanDevices().then(s => {
  const result = JSON.parse(s);
  console.log(result.paired, result.found);
});

✅ connect / unpair

BluetoothManager.connect(device.address)
  .then(() => console.log('Connected!'))
  .catch(e => alert(e));

BluetoothManager.unpair(device.address)
  .then(() => console.log('Unpaired'))
  .catch(e => alert(e));

📡 Events

| Event Key | Description | |------------|--------------| | EVENT_DEVICE_ALREADY_PAIRED | Emits paired devices array | | EVENT_DEVICE_DISCOVER_DONE | Emits when scanning completes | | EVENT_DEVICE_FOUND | Emits when new device found | | EVENT_CONNECTION_LOST | Emits when connection lost | | EVENT_UNABLE_CONNECT | Emits when connection fails | | EVENT_CONNECTED | Emits when connected | | EVENT_BLUETOOTH_NOT_SUPPORT | Device does not support BT (Android only) |


🖨️ BluetoothTscPrinter (Label Printer)

Used for label printing.

✅ printLabel(options)

BluetoothTscPrinter.printLabel(options)
  .then(() => console.log('Label printed'))
  .catch(err => console.error(err));

Example Options

const options = {
  width: 40,
  height: 30,
  gap: 20,
  direction: BluetoothTscPrinter.DIRECTION.FORWARD,
  reference: [0, 0],
  tear: BluetoothTscPrinter.TEAR.ON,
  sound: 0,
  text: [
    {
      text: 'Sample Text',
      x: 20, y: 0,
      fonttype: BluetoothTscPrinter.FONTTYPE.SIMPLIFIED_CHINESE,
      rotation: BluetoothTscPrinter.ROTATION.ROTATION_0,
      xscal: BluetoothTscPrinter.FONTMUL.MUL_1,
      yscal: BluetoothTscPrinter.FONTMUL.MUL_1
    }
  ],
  qrcode: [
    { x: 20, y: 96, level: BluetoothTscPrinter.EEC.LEVEL_L, width: 3, code: 'show me the money' }
  ],
  barcode: [
    { x: 120, y: 96, type: BluetoothTscPrinter.BARCODETYPE.CODE128, height: 40, readable: 1, code: '1234567890' }
  ],
  image: [
    { x: 160, y: 160, mode: BluetoothTscPrinter.BITMAP_MODE.OVERWRITE, width: 60, image: base64Image }
  ]
};

🧾 BluetoothEscposPrinter (Receipt Printer)

Follows ESC/POS command set for text & image printing.

✅ printerInit

Initialize printer.

✅ printText(text, options)

Prints text with options:

BluetoothEscposPrinter.printText("Hello World\n", {
  encoding: 'GBK',
  widthtimes: 1,
  heigthtimes: 1,
  fonttype: 0,
  cut: true
});

✅ printPic(base64, options)

Prints image (base64 encoded).

Options:

| Key | Type | Description | |-----|------|--------------| | width | int | Target width (dots) | | left | int | Left padding (ignored if center true) | | center | bool | Center horizontally | | autoCut | bool | Auto-cut after print (default true) | | paperSize | int | Paper width (58 / 80 mm) |

Example:

BluetoothEscposPrinter.printPic(base64Image, {
  width: 384,
  center: true,
  paperSize: 80,
  autoCut: false
});

✅ printColumn

Print columns (table-style layout).

await BluetoothEscposPrinter.printColumn(
  [12, 6, 6, 8],
  [BluetoothEscposPrinter.ALIGN.LEFT, BluetoothEscposPrinter.ALIGN.CENTER, BluetoothEscposPrinter.ALIGN.CENTER, BluetoothEscposPrinter.ALIGN.RIGHT],
  ['Item', 'Qty', 'Price', 'Total'],
  {}
);

🧾 Full Example: Print a Receipt

await BluetoothEscposPrinter.printerAlign(BluetoothEscposPrinter.ALIGN.CENTER);
await BluetoothEscposPrinter.printText("My Store\n\r", { widthtimes: 3, heigthtimes: 3 });
await BluetoothEscposPrinter.printText("Sales Receipt\n\r", {});
await BluetoothEscposPrinter.printerAlign(BluetoothEscposPrinter.ALIGN.LEFT);
await BluetoothEscposPrinter.printText("Customer: Retail\n\r", {});
await BluetoothEscposPrinter.printText("Invoice: INV20251014\n\r", {});
await BluetoothEscposPrinter.printText("--------------------------------\n\r", {});
let columnWidths = [12, 6, 6, 8];
await BluetoothEscposPrinter.printColumn(columnWidths,
  [0, 1, 1, 2],
  ['Product', 'Qty', 'Price', 'Total'],
  {}
);
await BluetoothEscposPrinter.printText("--------------------------------\n\r", {});
await BluetoothEscposPrinter.printText("Total: $64.00\n\r", {});
await BluetoothEscposPrinter.printText("Thank you!\n\r\n\r", {});

💡 Open Drawer

BluetoothEscposPrinter.openDrawer(0, 250, 250);

🔗 References