@react-pdf/renderer lets developers define PDF layouts with React components. The same documents render in the browser or on Node as files, streams, or blobs.
Overview
react-pdf, published as @react-pdf/renderer, is a React renderer aimed at authoring PDF documents with familiar component syntax instead of low-level PDF APIs. It is meant for creating new PDFs programmatically, distinct from viewers that display existing PDF files.
Documents are built as React element trees. Layout relies on Yoga flexbox semantics, supporting rows, columns, wrapping, and absolute positioning similar to web flex layouts. Rendering targets both client-side environments and Node so reports can be generated on demand or in backend jobs.
Support includes custom fonts, images, SVG, form fields, hyphenation, and control over page breaks. Output can be saved to disk on the server, streamed, or produced as blobs in the browser. Guides and an online playground show multi-section report layouts.
Installation is via npm for JavaScript projects already using React. The package sits in application dependency trees as a library imported into code rather than a standalone desktop or hosted service.
Key features
- React component PDF authoring
- Browser and Node rendering
- Flexbox layout via Yoga
- Custom fonts and images
- SVG and form fields
- Page break control
- Stream, blob, or file output
- Interactive documentation playground
Use cases
- Programmatic business reports
- Server-generated invoice PDFs
- Client-side PDF export buttons
- Data-driven printable documents