Skip to content

react-pdf

A React renderer that creates PDF files in the browser or on a server.

Stars
16.8k
Forks
1.3k
Licence
MIT
Language
TypeScript
Last update
6 days ago
Type
Library

What it is

react-pdf (published as @react-pdf/renderer) lets developers describe a document with React components such as Document, Page, View and Text, then produces a PDF from it. It works in the browser, where a PDFViewer component can display the result, and in Node.js, where render can save the PDF to a file. It is useful when you want PDFs generated from the same component model as the rest of a React app.

  • Render a multi-section A4 page with styled views and text
  • Show a live PDF preview inside a web page with PDFViewer
  • Save a generated document to a file on the server with ReactPDF.render

Great for

  • React developers who need to generate PDF reports or invoices
  • Teams that want PDF layouts written as reusable components
  • Node.js projects that save generated PDFs to disk
  • Browser apps that preview a PDF before download

Not ideal for

  • People who only need to display an existing PDF, since the README points to a different project (wojtekmaj/react-pdf) for that
  • Non-developers looking for a no-code PDF editor
  • Projects not using React, since the library is a React renderer
Step-by-step guide: how to use react-pdfInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Node.js · yarn or another npm-compatible package manager

    Install the package

    yarn add @react-pdf/renderer
  2. 2

    Run it

    • Install the package with yarn add @react-pdf/renderer
    • Define a document component using Document, Page, View and Text
    • In the browser, wrap the document in PDFViewer to preview it
    • In Node.js, call ReactPDF.render(<MyDocument />, path) to save a file
  3. 3

    Get the most out of it

    • Use StyleSheet.create to keep page and section styles in one place
    • Use flexbox properties such as flexDirection and flexGrow for layout, as shown in the README example
    • Use PDFViewer during development to check output before generating files
    • Read the project homepage at react-pdf.org for the full API and guides

Downloads

Strengths

  • Uses React components and StyleSheet, so familiar patterns carry over
  • Supports both browser and Node.js rendering as described in the README
  • Open source under the MIT license with a large community (about 16.8k stars)

Trade-offs

  • The README is short and does not document every feature, so check the homepage for details
  • The README's Node example uses an older ReactDOM.render API, so verify current usage against the docs
  • Layout is driven by styles in the README example (flexbox-style), which may take time to learn for print layouts

How it compares

ProjectStarsTypeLevelUpdatedBest for
react-pdf (this)16.8kLibraryintermediate6 days agoReact developers who need to generate PDF reports or invoices
jsPDF31.3kLibrarybeginner5 days agoWeb developers who need to let users download a generated PDF from a page
pdfkit10.7kLibrarybeginner4 days agoNode.js developers who need to generate PDFs such as invoices or reports from application data
markitdown193kLibrarybeginner9 days agoDevelopers building LLM or text analysis pipelines that need document text
Semantic-UI51kLibrarybeginner1.9 years agoFront-end developers who want prebuilt UI components they can restyle with themes
bulma50kLibrarybeginner2 months agoDevelopers who want a quick, consistent styling baseline for a web page

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.