react-pdf (diegomura/react-pdf) is a library that lets developers generate PDF files using React, the same component-based approach used to build web interfaces. Rather than building a PDF document with a specialized PDF tool, you describe the document using familiar React building blocks like Document, Page, View, and Text. The library works in two environments. In a web browser, you can embed a PDF viewer directly in a page using a PDFViewer component, so users see the generated document without leaving the site. On the server side (Node.js runtime), you can save the PDF directly to a file on disk. This means you can use the same code to generate invoices, reports, or any structured document and either display it live or store it. Styling works through a StyleSheet system that uses flexbox (a layout model borrowed from web CSS that controls how elements are arranged and sized), so developers who already know how to lay out web pages can apply that same knowledge to PDF layouts. The README's code examples show how you define a document as a React component, apply styles (like page background color, padding, and margins), and then render it, either to a browser viewer or to a file. The library is written in TypeScript, available via npm, and licensed under MIT (free to use and modify). It is distinct from another similarly named package that only displays existing PDFs rather than creating new ones.
Generated 2026-05-21 · Model: sonnet-4-6 · Verify against the repo before relying on details.