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 🙏

© 2026 – Pkg Stats / Ryan Hefner

nitro-print-service-sdk

v1.0.2

Published

JavaScript/TypeScript client for Nitro local printer service

Readme

Nitro Print Service SDK

A lightweight TypeScript/JavaScript SDK for communicating with the Nitro Print Service to discover printers and send print jobs.

Installation

npm install nitro-print-service-sdk

Requirements

Before using this package, make sure your Nitro Print Service is running on the machine.

The SDK communicates with:

http://127.0.0.1:9191

Important: Print Data

The print() function expects the print data as a Base64-encoded string.

You need to create the raw ESC/P commands for your printer, convert them into a Buffer, and then convert that buffer to Base64 before sending it to the SDK.

For example:

const label = new BrotherLabelBuilder()
  // --- Item Number ---
  .align("center")
  .bold(true)
  .fontSanSerif()
  .fontSize(35)
  .text(`#: ${data.itemNumber}`)
  .lineBreak(1)
  .bold(false)

  // --- Details ---
  .align("left")
  .fontSize(22)
  .lineSpacing(40)
  .text(`Name:   ${data.itemName}\n`)
  .text(`Stream: ${data.streamName.toUpperCase()}\n`)
  .text(`Date:   ${formattedDate} ${formattedTime}`);

// Build the raw ESC/P binary payload
const payloadBuffer: Buffer = label.buildPayload();

// Convert the raw payload to Base64
const base64Data = payloadBuffer.toString("base64");

You can then pass the Base64 data to print():

import { print } from "nitro-print-service-sdk";

const result = await print({
  printerName: "Brother QL-820NWB",
  base64Data,
});

console.log(result);

If you don't specify printerName, the Nitro Print Service can use the default printer:

const result = await print({
  base64Data,
});

Get Available Printers

Use getPrinters() to retrieve the printers available on the machine:

import { getPrinters } from "nitro-print-service-sdk";

try {
  const printers = await getPrinters();

  console.log(printers);
} catch (error) {
  console.error("Failed to get printers:", error);
}

Example response:

[
  {
    name: "Brother QL-820NWB",
    displayName: "Brother QL-820NWB",
    description: "Brother Label Printer",
    isDefault: true
  }
]

Print

The print() function accepts a PrintRequest:

interface PrintRequest {
  printerName?: string;
  base64Data: string;
}

Example:

import { print } from "nitro-print-service-sdk";

try {
  const result = await print({
    printerName: "Brother QL-820NWB",
    base64Data,
  });

  console.log(result);
} catch (error) {
  console.error("Print failed:", error);
}

API

getPrinters()

Returns all available printers.

getPrinters(): Promise<Printer[]>

print(request)

Sends the Base64-encoded ESC/P print data to the selected printer.

print(request: PrintRequest): Promise<PrintResponse>

Types

Printer

interface Printer {
  name: string;
  displayName?: string;
  description?: string;
  isDefault: boolean;
}

PrintRequest

interface PrintRequest {
  printerName?: string;
  base64Data: string;
}

PrintResponse

interface PrintResponse {
  status: "success" | "error";
  message: string;
}

PrintersResponse

interface PrintersResponse {
  status: "success" | "error";
  message?: string;
  defaultPrinter: string | null;
  printers: Printer[];
}

Error Handling

Both getPrinters() and print() throw an Error when the request fails.

try {
  const printers = await getPrinters();

  const result = await print({
    base64Data,
  });
} catch (error) {
  console.error(error);
}

Local Nitro Print Service

Make sure the Nitro Print Service is running before using this SDK.

The SDK communicates with:

http://127.0.0.1:9191

Available endpoints:

GET  /printers
POST /print

The SDK does not start the Nitro Print Service. The service must already be running on the user's machine.