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

printer-service-package

v1.0.5

Published

Vue local printer service helper to list and print to local printers and sync to Laravel database

Readme

🖨️ Printer Service Node Package

npm version License: MIT

A lightweight, robust, and developer-friendly Vue 3 composable package to handle local printer integrations smoothly. Perfect for Point of Sale (POS) systems, thermal receipt printers, and automated waybill/invoice printing workflows.

[!IMPORTANT] Desktop App Required: To use this package, you must download and run the PrintBridge desktop application from https://premod.me/printbridge.


✨ Features

  • 🔌 Zero Configuration Connection: Connect to the local PrintBridge hardware server queue effortlessly.
  • 🖨️ Thermal & HTML Printing: Send raw or styled HTML templates directly to thermal/receipt printers (supporting default 80mm and custom widths).
  • 🚦 Real-time Status Monitoring: Check printer availability, connection health, and queue status reactively using Vue refs.
  • 🛡️ Production Ready: Built-in timeout setups, automated error catch handling, and detailed logs to prevent queue blocking.

📦 Installation

Install the package via NPM:

npm install printer-service-package

Quick Start

Here is a simple example showing how to fetch available printers, select one, and print an HTML document from a Vue 3 component (using <script setup>):

<template>
  <div class="printer-card">
    <h3>🖨️ Print Terminal</h3>

    <!-- Fetch printers button -->
    <button @click="loadPrinters" :disabled="isChecking">
      {{ isChecking ? 'Checking connection...' : 'Refresh Printer List' }}
    </button>

    <!-- Printer selection dropdown -->
    <div v-if="printers.length > 0" class="controls">
      <select v-model="selectedPrinter">
        <option disabled value="">Select local printer</option>
        <option v-for="printer in printers" :key="printer.name" :value="printer.name">
          {{ printer.name }}
        </option>
      </select>

      <!-- Print action -->
      <button @click="handlePrint" :disabled="!selectedPrinter">
        Print Test Page
      </button>
    </div>

    <!-- Live Status / Error logs -->
    <div v-if="isConnected" class="badge online">Print Server Online</div>
    <div v-else class="badge offline">Print Server Offline</div>
    
    <p v-if="lastError" class="error-text">{{ lastError }}</p>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useLocalPrinterService } from 'printer-service-package'

// Initialize the composable
const { 
  printers, 
  isConnected, 
  isChecking, 
  lastError, 
  getPrinters, 
  printHTML 
} = useLocalPrinterService({
  port: '8080',   // Port of local PrintBridge service (default: 8080)
  timeout: 5000   // Request timeout limit (default: 5000ms)
})

const selectedPrinter = ref('')

const loadPrinters = async () => {
  await getPrinters()
}

const handlePrint = async () => {
  if (!selectedPrinter.value) return
  try {
    const htmlReceipt = '<h1>Invoice #1024</h1><p>Thank you for your purchase!</p>'
    await printHTML(selectedPrinter.value, htmlReceipt, '80mm')
    alert('Print job successfully queued!')
  } catch (error) {
    alert('Print failed: ' + error.message)
  }
}
</script>

<style scoped>
.printer-card { padding: 16px; border: 1px solid #eaeaea; border-radius: 8px; }
.controls { margin: 12px 0; display: flex; gap: 8px; }
.badge { display: inline-block; padding: 4px 8px; border-radius: 4px; font-size: 12px; color: white; }
.online { background: #4caf50; }
.offline { background: #f44336; }
.error-text { color: #f44336; font-size: 13px; margin-top: 8px; }
</style>

🛠️ API Reference

useLocalPrinterService(options)

Hook to control the local printing service. Accepts an optional configuration object:

  • port (string, default: '8080'): The port of the local PrintBridge app.
  • baseUrl (string): Complete custom URL (overrides port).
  • timeout (number, default: 5000): Connection timeout in milliseconds.

State (Reactive Ref Values)

  • isConnected (Ref): true if the local PrintBridge service responds to queries.
  • isChecking (Ref): true while the service state is being verified.
  • printers (Ref): A list of available local printer objects (e.g. [{ name: 'Epson_TM_T88' }]).
  • lastError (Ref): Contains details of the last failed request.

Methods

  • checkConnection(): Verifies if the desktop client is running. Returns Promise<boolean>.
  • getPrinters(): Updates and returns the list of available system printers. Returns Promise<array>.
  • printHTML(printerName, htmlContent, width): Sends an HTML payload with the specified width (default: '80mm') to the local print queue. Returns Promise<any>.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.