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

react-native-brother-print-android

v1.0.0

Published

React Native module for Brother Print SDK - Android only

Downloads

31

Readme

react-native-brother-print

React Native module for Brother Print SDK - Android only. This module provides silent printing capabilities for Brother printers without showing system print dialogs.

Features

  • Silent printing - Print text directly without user interaction
  • Printer discovery - Find Brother printers on WiFi, Bluetooth, and USB
  • Connection management - Connect and disconnect from printers
  • Status checking - Monitor printer status and battery level
  • Configurable printing - Font size, alignment, copies, and more
  • TypeScript support - Full type definitions included
  • Promise-based APIs - Modern async/await support

Supported Platforms

  • ✅ Android (API 21+)
  • ❌ iOS (not supported - Android only)

Installation

npm install react-native-brother-print

Android Setup

  1. Copy the Brother SDK AAR file to your Android project:

    cp node_modules/react-native-brother-print/android/libs/BrotherPrintLibrary.aar android/app/libs/
  2. Add the module to your MainApplication.java:

    import com.brotherprint.BrotherPrintPackage;
    
    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new BrotherPrintPackage()  // Add this line
      );
    }
  3. Add required permissions to your AndroidManifest.xml:

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    <uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  4. Request runtime permissions in your app:

    import { PermissionsAndroid, Platform } from 'react-native';
    
    if (Platform.OS === 'android') {
      await PermissionsAndroid.requestMultiple([
        PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
        PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN,
        PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT,
      ]);
    }

Usage

import BrotherPrintModule from 'react-native-brother-print';

// Search for printers
const printers = await BrotherPrintModule.searchPrinters(15000);

// Connect to a printer
const connected = await BrotherPrintModule.connectPrinter(printers[0]);

// Print text with options
const options = {
  fontSize: 12,
  fontBold: false,
  alignment: 'center',
  copies: 1,
  cutAtEnd: true,
  autoCut: true,
};

const success = await BrotherPrintModule.printText('Hello World!', options);

// Check printer status
const status = await BrotherPrintModule.getPrinterStatus();

// Disconnect
await BrotherPrintModule.disconnect();

API Reference

Methods

searchPrinters(timeoutMs?: number): Promise<PrinterInfo[]>

Discover available Brother printers on the network.

  • timeoutMs - Search timeout in milliseconds (default: 15000)
  • Returns array of PrinterInfo objects

connectPrinter(printerInfo: PrinterInfo): Promise<boolean>

Connect to a specific printer.

  • printerInfo - Printer information from search results
  • Returns true if connection successful

printText(text: string, options?: PrintOptions): Promise<boolean>

Print text to the connected printer.

  • text - Text to print (supports \\n for line breaks)
  • options - Print configuration options
  • Returns true if print successful

getPrinterStatus(): Promise<PrinterStatus>

Get the current status of the connected printer.

  • Returns PrinterStatus object with error info and battery status

disconnect(): Promise<boolean>

Disconnect from the current printer.

  • Returns true if disconnect successful

Types

PrinterInfo

interface PrinterInfo {
  id: string;
  modelName: string;
  ipAddress?: string;
  macAddress?: string;
  serialNumber?: string;
  nodeName?: string;
  location?: string;
  channelType: 'WiFi' | 'Bluetooth' | 'BluetoothLE' | 'USB';
}

PrintOptions

interface PrintOptions {
  fontSize?: number;           // Font size (default: 12)
  fontBold?: boolean;          // Bold text (default: false)
  alignment?: 'left' | 'center' | 'right';  // Text alignment (default: 'left')
  copies?: number;             // Number of copies (default: 1)
  cutAtEnd?: boolean;          // Cut paper at end (default: true)
  autoCut?: boolean;           // Auto cut paper (default: true)
}

PrinterStatus

interface PrinterStatus {
  isOnline: boolean;
  errorStatus: string[];
  mediaType?: string;
  mediaSize?: string;
  batteryLevel?: number;
  batteryStatus?: 'Full' | 'Half' | 'Low' | 'Replace' | 'Unknown';
}

Example App

The package includes a complete example app demonstrating all features:

  • Printer discovery
  • Connection management
  • Text printing with configurable options
  • Status checking
  • Error handling

To run the example:

cd example
npm install
npx react-native run-android

Supported Brother Printers

This module supports Brother printers compatible with the Brother Mobile SDK, including:

  • P-touch series - Label printers
  • QL series - Label printers
  • PocketJet series - Mobile printers
  • MW series - Mobile printers
  • RJ series - Mobile printers
  • TD series - Desktop printers

Error Handling

All methods return promises that reject with descriptive error messages:

try {
  const printers = await BrotherPrintModule.searchPrinters();
} catch (error) {
  console.error('Search failed:', error.message);
  // Handle specific error codes
  if (error.code === 'BLUETOOTH_ERROR') {
    // Handle Bluetooth issues
  }
}

Troubleshooting

Printer Discovery Issues

  • Ensure printer and device are on the same WiFi network
  • Check that the printer is powered on and not in sleep mode
  • Verify all required permissions are granted
  • For Bluetooth printers, make sure Bluetooth is enabled

Connection Problems

  • Verify printer is not connected to another device
  • Check network connectivity
  • Ensure printer model is supported
  • Try power cycling the printer

Print Failures

  • Check printer paper and ink/toner levels
  • Verify printer is online and ready
  • Ensure text formatting is correct
  • Check for printer error conditions

License

MIT

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Support

For issues and questions: