Installation
Package Manager
bash
pnpm add @thermal-print/reactbash
npm install @thermal-print/reactbash
yarn add @thermal-print/reactAdditional Packages
For PDF generation (browser printing):
bash
pnpm add @thermal-print/pdfbash
npm install @thermal-print/pdfFor direct ESC/POS control:
bash
pnpm add @thermal-print/escposbash
npm install @thermal-print/escposPeer Dependencies
@thermal-print/react requires React 16.8+ as a peer dependency:
bash
pnpm add react react-domTypeScript
All packages include TypeScript definitions out of the box. No additional @types packages needed.
Quick Start
tsx
import { Document, Page, Text, convertToESCPOS } from '@thermal-print/react';
function Receipt() {
return (
<Document>
<Page>
<Text>Hello, Thermal Printer!</Text>
</Page>
</Document>
);
}
// Convert to ESC/POS
const buffer = await convertToESCPOS(<Receipt />);
// Send to printer (implementation depends on your setup)
await printer.write(buffer);