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

@taprel/react

v0.1.0

Published

Taprel for React: hooks for silent printing from web apps, through the desktop agent

Readme

Taprel for React

Silent printing from React apps: your page calls these hooks, and the Taprel desktop agent on the customer's PC prints with no print dialog. Works with Vite, Next.js and React 18 or newer.

Install

npm install @taprel/react

This brings @taprel/sdk with it, and everything in the SDK can be imported from here. Printing also needs the Taprel agent installed on the PC with the printer. It's for Windows for now.

Print a receipt

import { PrintHelp, TaprelProvider, receipt, usePrint } from "@taprel/react";

function PrintButton() {
  const { print, isPrinting, error } = usePrint();

  return (
    <>
      <PrintHelp />
      <button
        disabled={isPrinting}
        onClick={() =>
          print(
            receipt([
              { text: "Café Central", align: "center", bold: true, size: 2 },
              { line: true },
              { row: ["2 x Coffee", "6.00"] },
              { row: ["Total", "6.00"], bold: true },
              { cut: true },
            ]),
          )
        }
      >
        Print
      </button>
      {error && <p>{error.message}</p>}
    </>
  );
}

export default function App() {
  return (
    <TaprelProvider client={{ name: "my-pos" }}>
      <PrintButton />
    </TaprelProvider>
  );
}

The agent picks the customer's receipt printer, so no printer name ends up in your code. The SDK's README explains how to write documents and lists every error code.

When the customer gets asked

The first connection can show the customer two questions: the browser's and the agent's. Nothing here connects until you ask, so opening a page never shows them. They appear on the first print, on connect(), or on mount if you choose autoConnect.

PrintHelp tells the customer what to do while they wait, and when something is wrong. It shows nothing when all is well.

What's included

| Name | What it does | |---|---| | TaprelProvider | Holds the connection. Takes the SDK client's options, autoConnect, or your own printClient. Read once, when it mounts | | usePrint() | print, printPdf, printRaw, isPrinting, error, result, warnings, reset | | useTaprel() | status, error, agent, isConnected, connect, disconnect, client | | usePrinters({ kind }) | printers, isLoading, error, refresh. Loads once connected | | usePreview(document, { printer, printerKind, delayMs }) | src for an <img>, preview, isLoading, error. Asks once connected, when the content changes | | PrintHelp | The customer's next step, with no styles of its own. Takes texts, downloadUrl, downloadText, className | | usePrintHelp(texts) | The same message as { kind, message }, for your own UI |

Good to know

  • Failed prints: print gives null and sets error, so a click handler needs no try. Each call sends once and never retries, because a retry could print twice. After CONNECTION_LOST or REQUEST_TIMEOUT the job may still print, so let the person decide.
  • Double clicks: a second click sends a second print, so disable your button with isPrinting.
  • "Printed": a result means "handed to the print queue", not "came out on paper". A job for an offline printer waits in the queue.
  • Printer list: check each printer's status. The list doesn't update by itself, so call refresh from a click.
  • Previews: usePreview asks nothing until connected, so call connect() from a click if you want a preview before the first print.
  • Next.js: build documents with receipt() and label() anywhere, including server components. The hooks and PrintHelp run on the client, and they're already marked for it.
  • Other languages: pass your own texts to PrintHelp. The defaults are in English.

Development

  • npm test: builds and runs the tests in a pretend browser against a pretend agent

License

This package is MIT. The desktop agent it talks to is a separate product with its own terms.