The problem here is that the version of React your project is using (^18.2.0) is not compatible with the react-to-pdf package's definition, which requires react version ^16.5.2 to be installed. At first glance, this may seem like an invalid error: the package expects a version higher than 16.5.2, and you've installed something above 18.2.0. However, any major version bump will create an incompatible state. We can understand this explicitly by reading npm's documentation on this topic, which states the following:

Assuming the host complies with semver, only changes in the host package's major version will break your plugin. Thus, if you've worked with every 1.x version of the host package, use "^1.0" or "1.x" to express this. If you depend on features introduced in 1.5.2, use "^1.5.2".

Armed with all of that knowledge, we now have handful of options for resolving this issue:

  1. Force install the plugin or use the legacy peer dependencies option, either of which provides no guarantee that this package works with your version of react.
  2. Downgrade react (this is technically an option, but don't do it).
  3. Find a more up-to-date alternative that accomplishes the same goal and is compatible with your version of react.

Additionally, if you really like this package, I would recommend opening up an issue on the maintainer's repository to ask for an update that tests compatibility with newer versions and publishes a new version of their own package.

Finally, I would recommend becoming familiar with this kind of error message and read through some of the official documentation on npm's website because this kind of thing is fairly common and understanding the basics will save you many future headaches.

Answer from Wes Harper on Stack Overflow
🌐
npm
npmjs.com › package › react-pdf
react-pdf - npm
February 25, 2026 - Display PDFs in your React app as easily as if they were images.. Latest version: 10.4.1, last published: 2 months ago. Start using react-pdf in your project by running `npm i react-pdf`. There are 1051 other projects in the npm registry using ...
      » npm install react-pdf
    
Published   Feb 25, 2026
Version   10.4.1
🌐
npm
npmjs.com › package › react-to-pdf
react-to-pdf - npm
4 weeks ago - Create PDF documents from React Components. Latest version: 3.2.2, last published: 23 days ago. Start using react-to-pdf in your project by running `npm i react-to-pdf`. There are 27 other projects in the npm registry using react-to-pdf.
      » npm install react-to-pdf
    
Published   Mar 18, 2026
Version   3.2.2
🌐
npm
npmjs.com › package › @react-pdf › renderer
@react-pdf/renderer - npm
5 days ago - Latest version: 4.4.1, last published: 20 hours ago. Start using @react-pdf/renderer in your project by running `npm i @react-pdf/renderer`. There are 491 other projects in the npm registry using @react-pdf/renderer.
      » npm install @react-pdf/renderer
    
Published   Apr 10, 2026
Version   4.4.1
🌐
npm
npmjs.com › package › @pdf-viewer › react
@pdf-viewer/react - npm
February 16, 2026 - Latest version: 1.19.0, last published: 2 months ago. Start using @pdf-viewer/react in your project by running `npm i @pdf-viewer/react`. There are no other projects in the npm registry using @pdf-viewer/react.
      » npm install @pdf-viewer/react
    
Published   Feb 16, 2026
Version   1.19.0
🌐
React-pdf
react-pdf.org
React-pdf
React renderer for creating PDF files on the browser and server
🌐
Nutrient
nutrient.io › blog › sdk › how to build a reactjs pdf viewer with react pdf
How to build a React PDF viewer with react-pdf (2026) - Nutrient
January 28, 2026 - Install react-pdf (npm install react-pdf), import the Document and Page components, configure the PDF.js worker in the same file, and build your own navigation controls.
🌐
npm
npmjs.com › search
keywords:react-pdf - npm search
A simple light weight react package to extract plain text from a pdf file.
Top answer
1 of 2
1

The problem here is that the version of React your project is using (^18.2.0) is not compatible with the react-to-pdf package's definition, which requires react version ^16.5.2 to be installed. At first glance, this may seem like an invalid error: the package expects a version higher than 16.5.2, and you've installed something above 18.2.0. However, any major version bump will create an incompatible state. We can understand this explicitly by reading npm's documentation on this topic, which states the following:

Assuming the host complies with semver, only changes in the host package's major version will break your plugin. Thus, if you've worked with every 1.x version of the host package, use "^1.0" or "1.x" to express this. If you depend on features introduced in 1.5.2, use "^1.5.2".

Armed with all of that knowledge, we now have handful of options for resolving this issue:

  1. Force install the plugin or use the legacy peer dependencies option, either of which provides no guarantee that this package works with your version of react.
  2. Downgrade react (this is technically an option, but don't do it).
  3. Find a more up-to-date alternative that accomplishes the same goal and is compatible with your version of react.

Additionally, if you really like this package, I would recommend opening up an issue on the maintainer's repository to ask for an update that tests compatibility with newer versions and publishes a new version of their own package.

Finally, I would recommend becoming familiar with this kind of error message and read through some of the official documentation on npm's website because this kind of thing is fairly common and understanding the basics will save you many future headaches.

2 of 2
0

Try :

  • npm install react-to-pdf --force
  • Choose a previous stable version, for example npm install [email protected]
Find elsewhere
🌐
npm
npmjs.com › search
react pdf - npm search
JSON becomes PDF documents. ... vercel-release-bot• 0.16.0 • 12 days ago • 2 dependents • Apache-2.0published version 0.16.0, 12 days ago2 dependents licensed under $Apache-2.0 ... sophon.men• 3.1.2 • 5 months ago • 5 dependents • MITpublished version 3.1.2, 5 months ago5 dependents licensed under $MIT ... A simple React PDF viewer component using react-pdf.
🌐
npm
npmjs.com › package › react-pdf-js
react-pdf-js - npm
June 19, 2019 - Latest version: 5.1.0, last published: 7 years ago. Start using react-pdf-js in your project by running `npm i react-pdf-js`. There are 32 other projects in the npm registry using react-pdf-js.
      » npm install react-pdf-js
    
Published   Jun 19, 2019
Version   5.1.0
Author   mikecousins
🌐
npm
npmjs.com › package › @react-pdf › pdfkit
@react-pdf/pdfkit - npm
December 29, 2025 - A PDF generation library for Node.js. Latest version: 4.1.0, last published: 3 months ago. Start using @react-pdf/pdfkit in your project by running `npm i @react-pdf/pdfkit`. There are 68 other projects in the npm registry using @react-pdf/pdfkit.
      » npm install @react-pdf/pdfkit
    
Published   Dec 29, 2025
Version   4.1.0
Author   Devon Govett
🌐
GitHub
github.com › diegomura › react-pdf
GitHub - diegomura/react-pdf: 📄 Create PDF files using React
React renderer for creating PDF files on the browser and server
Starred by 16.5K users
Forked by 1.3K users
Languages   TypeScript 82.5% | JavaScript 17.4%
🌐
GitHub
github.com › ashishforgive › react-file-npm
GitHub - ashishforgive/react-file-npm: NPM package for converting any file in pdf. · GitHub
package for converting text or .doc to pdf in React Js. $ npm install react-doc-to-pdf #or $ yarn install react-doc-to-pdf
Author   ashishforgive
🌐
npm
npmjs.com › package › pdf-viewer-reactjs
pdf-viewer-reactjs - npm
import React from 'react' import PDFViewer from 'pdf-viewer-reactjs' const ExamplePDFViewer = () => { return ( <PDFViewer document={{ url: 'https://arxiv.org/pdf/quant-ph/0410100.pdf', }} /> ) } export default ExamplePDFViewer
      » npm install pdf-viewer-reactjs
    
Published   Feb 15, 2021
Version   2.2.3
Author   ansu5555
🌐
npm
npmjs.com › package › react-native-pdf
react-native-pdf - npm
3 weeks ago - Latest version: 7.0.4, last published: 22 days ago. Start using react-native-pdf in your project by running `npm i react-native-pdf`. There are 47 other projects in the npm registry using react-native-pdf.
      » npm install react-native-pdf
    
Published   Mar 19, 2026
Version   7.0.4
🌐
npm
npmjs.com › package › react-pdf-html
react-pdf-html - npm
Html component for react-pdf with CSS support. Latest version: 2.1.5, last published: 3 months ago. Start using react-pdf-html in your project by running `npm i react-pdf-html`. There are 24 other projects in the npm registry using react-pdf-html.
      » npm install react-pdf-html
    
Published   Dec 29, 2025
Version   2.1.5
🌐
React PDF Viewer
react-pdf-viewer.dev › docs › getting-started
Getting started - React PDF Viewer
React PDF Viewer uses the APIs provided by the popular pdfjs library. Execute the following command from the root folder to install pdfjs: npm install pdfjs-dist@3.4.120 ·
🌐
GitHub
github.com › wojtekmaj › react-pdf
GitHub - wojtekmaj/react-pdf: Display PDFs in your React app as easily as if they were images. · GitHub
This package is used to display existing PDFs. If you wish to create PDFs using React, you may be looking for @react-pdf/renderer. Install by executing npm install react-pdf or yarn add react-pdf.
Starred by 11K users
Forked by 999 users
Languages   TypeScript 94.5% | CSS 5.4% | HTML 0.1%
🌐
npm
npmjs.com › package › @simplepdf › react-embed-pdf
@simplepdf/react-embed-pdf - npm
January 17, 2026 - import { EmbedPDF } from "@simplepdf/react-embed-pdf"; // The PDF is displayed when rendering the component <EmbedPDF mode="inline" style={{ width: 900, height: 800 }} documentURL="https://cdn.simplepdf.com/simple-pdf/assets/sample.pdf" /> // ...
      » npm install @simplepdf/react-embed-pdf
    
Published   Jan 17, 2026
Version   1.10.0
Author   bendersej
🌐
Npm
npm.io › package › react-pdf
React-pdf NPM | npm.io
This package is used to display existing PDFs. If you wish to create PDFs using React, you may be looking for @react-pdf/renderer. Install by executing npm install react-pdf or yarn add react-pdf.