Print directly to Star printers from your NativeScript app.
npm i --save nativescript-star-printer

NativeScript Star Printer

NPM version Downloads Twitter Follow

That's the demo app in action, printing on a Star Micronics TSP650II


For NativeScript 7+, please use plugin version 4+

tns plugin add nativescript-star-printer


requiring / importing the plugin

All examples below assume you're using TypeScript, but here's how to require the plugin with plain old JS as well:


var StarPrinterPlugin = require("nativescript-star-printer");
var starPrinter = new StarPrinterPlugin.StarPrinter();


import { StarPrinter, SPPrinter, SPCommands } from "nativescript-star-printer";

export Class MyPrintingClass {
private starPrinter: StarPrinter;

constructor() {
this.starPrinter = new StarPrinter();


If you're searching for a Bluetooth printer, enable Bluetooth in the device settings and pair/connect the printer. Then do:

(printers: Array<SPPrinter>) => {
console.log(`Found ${printers.length} printers`);
}, (err: string) => {
console.log(`Search printers error: ${err}`);

The most useful property on the SPPrinter class is the portName which you will need in other API methods.

The only other property is modelName.


Once you know the printer port name, you can connect to it.

Note that there's no need to connect if you want to print as the print function does this automatically.

portName: thePortName
}).then((result: SPPrinterStatusResult) => console.log("Connected: " + result.connected));


After connecting to a printer, you can use this method to poll for the 'online' and 'paper' statuses.

portName: this.lastConnectedPrinterPort
}).then(result => {
const online: boolean =;
const onlineStatus: PrinterOnlineStatus = result.onlineStatus;
const paperStatus: PrinterPaperStatus = result.paperStatus;


Once you've got the port of the printer you want to print to, just do:

portName: this.selectedPrinterPort,
commands: commands

So what are those commands? Let's recreate the fake receipt below to answer that (see the TypeScript definition for all options):

const image = ImageSource.fromFile("~/res/mww-logo.png");

// Note that a standard 3 inch roll is 48 characters wide - we use that knowledge for our "columns"
let commands = new SPCommands()
true, // diffuse
true // align center (set to 'false' to align left)
.text("My Awesome Boutique").newLine()
.text("In a shop near you").newLine()
.text("Planet Earth").newLine()
.text("Date: 11/11/2017 Time: 3:15 PM")
.horizontalLine() // you can pass in the character and the nr of characters (use 48 for a 3" roll, 42 for a smaller one)
SKU Description Total").newLine()
300678566 Plain White Tee €10.99").newLine()
300692003 Black Dénim €29.99").newLine()
300651148 Blue Denim €29.99").newLine()
type: "
value: "
width: "
height: 60,
appendEncodedValue: false

portName: this.selectedPrinterPort,
commands: commands


In case a cash drawer is connected via the UTP (network) connector of the Star printer, you can open the drawer from your code!

portName: this.selectedPrinterPort

iOS runtime permission reason

iOS 10+ requires a permission popup when connecting (the first) time to a Bluetooth peripheral explaining why it needs to connect.

You can provide your own reason by adding something like this to app/App_Resources/ios/Info.plist:

<string>My reason justifying fooling around with your Bluetooth</string>

To not crash your app in case you forgot to provide the reason this plugin adds an empty reason to the .plist during build. This value gets overridden by anything you specified yourself. You're welcome.

Known limitations

On iOS you want to run this on a real device.

Future work

Possibly add more print formatting options.