If you goal is just to view the pdf in your application, the easiest way is using the object tag in HTML. You don't need to import any libraries and works most of the browsers. But this is lack of customization and styles.

  <object data="http://africau.edu/images/default/sample.pdf" type="application/pdf" width="100%" height="100%">
      <p>Alternative text - include a link <a href="http://africau.edu/images/default/sample.pdf">to the PDF!</a></p>
  </object>
Answer from Dhanuka Perera on Stack Overflow
🌐
npm
npmjs.com › package › react-pdf
react-pdf - npm
Latest version: 10.2.0, last published: 2 months ago. Start using react-pdf in your project by running `npm i react-pdf`. There are 985 other projects in the npm registry using react-pdf.
      » npm install react-pdf
    
Published   Oct 09, 2025
Version   10.2.0
Author   Wojciech Maj
🌐
React PDF Viewer
react-pdf-viewer.dev › docs › basic-usage
Basic usage - React PDF Viewer
To display a PDF document, you have to pass its URL to the viewer's `fileUrl` parameter: ... The `fileUrl` accepts various sources of documents, including a base 64 string, an array of bytes, or a URL.
🌐
Nutrient
nutrient.io › blog › sdk › how to build a reactjs viewer with pdfjs
Build a React PDF viewer with PDF.js and Next.js: Step-by-step tutorial
July 16, 2025 - Learn how to build a fast, customizable PDF viewer in React using PDF.js and Next.js. Includes full code examples, setup instructions, and a comparison with Nutrient’s feature-rich PDF SDK.
🌐
PDF.js Express
pdfjs.express › documentation › get-started-viewer › react
Integrate React & JavaScript PDF Viewer | PDF.js Express Viewer SDK
import WebViewer from '@pdftron/pdfjs-express-viewer'; Create a reference where WebViewer will be placed or mounted. const MyComponent = () => { const viewer = useRef(null); return ( <div className="MyComponent"> <div className="header">React ...
🌐
Nutrient
nutrient.io › blog › sdk › how to build a reactjs pdf viewer with react pdf
React PDF viewer: Complete guide to building with react-pdf in 2025
August 12, 2025 - To create a React PDF viewer with react-pdf: 1) Install the library (npm install react-pdf), 2) Import Document and Page components, 3) Configure the PDF.js worker, and 4) Build your own UI controls.
🌐
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
🌐
GitHub
github.com › react-pdf-viewer › react-pdf-viewer
GitHub - react-pdf-viewer/react-pdf-viewer: A React component to view a PDF document
// Core viewer import { Viewer ... defaultLayoutPluginInstance, ... ]} /> ... Can open a file from local. Users can drag and drop a local file to view it...
Starred by 2.6K users
Forked by 295 users
Languages   TypeScript 97.5% | CSS 2.5%
Find elsewhere
🌐
GitHub
github.com › wojtekmaj › react-pdf
GitHub - wojtekmaj/react-pdf: Display PDFs in your React app as easily as if they were images.
Add React-PDF to your project by executing npm install react-pdf or yarn add react-pdf. If you use Next.js prior to v15 (v15.0.0-canary.53, specifically), you may need to add the following to your next.config.js:
Starred by 10.7K users
Forked by 981 users
Languages   TypeScript 94.3% | CSS 5.6% | HTML 0.1%
🌐
PDF.js Express
pdfjs.express › documentation › get-started › react
Integrate React & JavaScript PDF Viewer | PDF.js Express SDK
Inside of useEffect hook or componentDidMount lifecycle method initialize WebViewer. Ensure that the path property in the constructor points to where you copied static assets node_modules/@pdftron/pdfjs-express/public in React public folder. ...
🌐
GitHub
github.com › mikecousins › react-pdf-js
GitHub - mikecousins/react-pdf-js: A React component to wrap PDF.js
import React, { useState, useRef } from 'react'; import { usePdf } from '@mikecousins/react-pdf'; const MyPdfViewer = () => { const [page, setPage] = useState(1); const canvasRef = useRef(null); const { pdfDocument, pdfPage } = usePdf({ file: 'test.pdf', page, canvasRef, }); return ( <div> {!pdfDocument && <span>Loading...</span>} <canvas ref={canvasRef} /> {Boolean(pdfDocument && pdfDocument.numPages) && ( <nav> <ul className="pager"> <li className="previous"> <button disabled={page === 1} onClick={() => setPage(page - 1)}> Previous </button> </li> <li className="next"> <button disabled={page === pdfDocument.numPages} onClick={() => setPage(page + 1)} > Next </button> </li> </ul> </nav> )} </div> ); }; When you call usePdf you'll want to pass in a subset of these props, like this:
Starred by 799 users
Forked by 151 users
Languages   TypeScript 90.7% | JavaScript 6.9% | CSS 2.0% | HTML 0.4%
🌐
npm
npmjs.com › package › @pdf-viewer › react
pdf-viewer/react
Latest version: 1.13.1, last published: 5 days 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   Dec 04, 2025
Version   1.13.1
Author   React PDF Viewer
🌐
React-pdf
react-pdf.org
React-pdf
React renderer for creating PDF files on the browser and server
🌐
Apryse
apryse.com › blog › building-react-pdf-viewer-with-pdfjs
How to Build a React PDF Viewer with PDF.js
October 17, 2018 - In our init function, we create an iframe and set its source to the PDF.js UI, and we use query params to tell the UI which PDF to render. Once the iframe is created, we append it to the DOM element passed into the init function. src/backen...
🌐
Stack Overflow
stackoverflow.com › questions › 73919619 › how-to-use-pdf-js-with-react
reactjs - How to use PDF.JS with React? - Stack Overflow
Your component only runs getPDFDoc on mount since pdfFile is missing in the usecallback deps, so when the file changes, it probably doesn't even notice as your effect won't re-run since getPDFDoc is referentially stable when it shouldn't be. ... import * as PDFJS from "pdfjs-dist/build/pdf"; import * as pdfjsWorker from "pdfjs-dist/build/pdf.worker.entry"; window.PDFJS = PDFJS; export default function PDFViewer({ pdfFile }) { PDFJS.GlobalWorkerOptions.workerSrc = pdfjsWorker; const getPDFDoc = useCallback(async () => { if (!pdfFile) return const doc = await PDFJS.getDocument(pdfFile); doc.promise.then( (loadedPdf) => { setPdfRef(loadedPdf); }, function (reason) { console.error(reason); } ); }, [pdfFile]); useEffect(() => { getPDFDoc(); }, [getPDFDoc]);
🌐
ComPDF
compdf.com › blog › build-a-react.js-pdf-viewer-with-react-pdf
How to Build a React.js PDF Viewer with React PDF | ComPFKit
In this article, you will first learn how to use the open-source React-PDF library to build a PDF viewer. Then, we introduce how to create a feature-rich ComPDFKit React.js PDF viewer.
🌐
Reddit
reddit.com › r/react › how to use mozilla pdf.js with react.js for client-side rendering & basic tools?
r/react on Reddit: How to Use Mozilla PDF.js with React.js for Client-Side Rendering & Basic Tools?
July 27, 2023 -

Hey everyone,

I hope you're all doing well! 🖐️

I'm currently working on a React.js project that involves rendering PDFs on the client side, and I stumbled upon Mozilla's PDF.js library. While it seems promising, I'm facing some challenges when it comes to integrating it into my project and adding some basic tools like annotations and highlighting.However, I've been struggling to find comprehensive documentation on how to integrate PDF.js with React.js effectively.

Has anyone here successfully used PDF.js with React.js before? I'd really appreciate some guidance on the best practices for integration and any tips or resources to add basic tools for annotations and highlighting.

Feel free to share your experiences, code snippets, or any helpful tutorials that you've come across. Your insights will be of great help to a fellow developer.

Thank you all in advance! 😊🙏