Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a simple PDF preview, put a browser-accessible PDF URL in an <iframe> or <object>. If you need React-controlled page rendering, custom controls, or integration with application state, use react-pdf (React-PDF), configure its matching PDF.js worker in the same module as the viewer, and make sure the PDF can be fetched under browser security rules.

One important distinction: react-pdf displays existing PDFs. @react-pdf/renderer creates PDFs from React components. They solve different problems.

Choose the right way to display a PDF

Approach Best for Trade-off
Native <iframe> or <object> A basic preview of a PDF at a URL the browser can access Little setup, but browser controls and behavior vary; the application has limited control over the viewer.
react-pdf with PDF.js React-rendered pages, custom controls, and app-state integration Requires worker and build configuration, plus loading, error, and page-rendering decisions.
PDF.js viewer layer A fuller viewer interface to adapt It is a separate layer on top of PDF.js’s display functionality. Mozilla asks sites embedding its viewer to reskin or build upon it rather than use it unmodified.

There is no complete browser compatibility matrix for native PDF embeds in the reviewed primary sources, so test the browsers and devices your application supports. For a React interface that needs to manage individual pages, react-pdf is usually the more controllable option.

Display a PDF with an iframe or object

Use a native embed when a browser-provided preview is sufficient. The URL must resolve to a PDF that the browser can access; for a PDF on another origin, the remote server’s policies and the browser affect whether it can be displayed.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
PDF Reader for Fire Tablet
  • PDF Reader for Fire Tablet
  • ✔Fast PDF Viewer
  • ✔Simple List of PDF Files
  • ✔Share and Print PDF
  • ✔55 Different Themes

Iframe

export default function PdfPreview() {
  return (
    <iframe
      src="/files/handbook.pdf"
      title="Employee handbook"
      width="100%"
      height="700"
    />
  );
}

Replace /files/handbook.pdf with the path or URL for your document. Give the frame a descriptive title and a useful height; otherwise, it may occupy too little space to be a usable preview. The browser supplies the PDF controls, so their appearance and available behavior are not controlled by React.

Object with a fallback

export default function PdfPreview() {
  return (
    <object
      data="/files/handbook.pdf"
      type="application/pdf"
      width="100%"
      height="700"
    >
      <p>
        The PDF could not be displayed here.
        <a href="/files/handbook.pdf">Open or download the PDF</a>.
      </p>
    </object>
  );
}

The fallback gives users another route if the browser does not display the embedded document. Neither native approach provides React with a page-by-page rendering interface.

Render PDF pages with React-PDF

The following example uses react-pdf to load a PDF, report its page count, and render its pages. It follows the project’s worker setup pattern: define workerSrc in the same module that renders Document and Page.

Check compatibility before installing

As stated in the React-PDF README checked on September 29, 2026, its latest branch requires React 19 or later and Node.js 22.13.0 or newer. The README lists Chrome 125 and Safari 18 (iOS 18) as minimum browser versions for that branch. Earlier browser versions may need polyfills, bundler transpilation, and the legacy worker; a polyfill alone does not extend support below those minimums. These requirements can change, so check the current React-PDF README against your app’s versions and target browsers before adopting the latest release.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install the library

In an existing project, add React-PDF using your package manager, for example:

Rank #2
npm install react-pdf

Use the package manager and dependency conventions already established in your project. Confirm that the installed React-PDF release, its PDF.js dependency, and your chosen worker file are compatible; the worker must match the PDF.js version used by the library.

Create the viewer component

import { useState } from 'react';
import { Document, Page, pdfjs } from 'react-pdf';

pdfjs.GlobalWorkerOptions.workerSrc = new URL(
  'pdfjs-dist/build/pdf.worker.min.mjs',
  import.meta.url,
).toString();

export default function PdfViewer({ file }) {
  const [numPages, setNumPages] = useState(0);

  return (
    <Document
      file={file}
      onLoadSuccess={({ numPages }) => setNumPages(numPages)}
    >
      {Array.from({ length: numPages }, (_, index) => (
        <Page key={index + 1} pageNumber={index + 1} />
      ))}
    </Document>
  );
}

Pass a PDF URL or another supported file value through the file prop. For example, render <PdfViewer file="/files/handbook.pdf" /> for a PDF served from your application. The page array starts at one because PDF page numbers are one-based; React keys use the same page number.

Add loading and error states

A production viewer should tell users when the document is loading and what to do if it fails. React-PDF’s Document supports load callbacks and loading/error content; a simple version can be written as:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<Document
  file={file}
  onLoadSuccess={({ numPages }) => setNumPages(numPages)}
  loading={<p>Loading PDF…</p>}
  error={<p>Could not load this PDF. Check the link or try again.</p>}
>
  {/* Render Page components after the document loads. */}
</Document>

For an interactive viewer, also show the current page and offer explicit next/previous controls rather than assuming users can rely on browser-native controls. The exact controls and navigation model are application choices; React-PDF renders the pages but does not dictate your product’s viewer design.

Framework and bundler checks

Worker resolution depends on the project build setup. The new URL(..., import.meta.url) pattern is the React-PDF project’s recommended approach, but verify that the bundler in your application can resolve and emit the worker asset. If the build cannot find the worker, follow the README instructions for that bundler and installed version rather than copying a worker from a different PDF.js release.

Rank #3
My PDF Reader
  • Open PDF files easily on your smartphone.
  • Cool User Interface and look.
  • Zoom and pan easily by using gesture with your fingers.
  • Scroll through pages easily vertically.
  • Fullscreen viewing capability.

With Next.js, the module that imports the viewer may need to skip server-side rendering. PDF rendering relies on browser capabilities, so if server rendering causes errors, isolate the viewer in a client-side module or use the framework’s client-only loading approach. Keep the worker configuration alongside the module that imports and renders Document and Page; the React-PDF README warns that module execution order can overwrite a worker setting configured elsewhere.

Cross-origin PDFs: CORS and proxying

When react-pdf loads a remote URL, PDF.js fetches the document through JavaScript. Browser same-origin rules apply: if the PDF is on another origin, that server must allow the request with suitable CORS headers, or your application must fetch it through a server-side proxy designed for the task. A URL that works in a native browser embed is not proof that PDF.js can fetch it from JavaScript. See the PDF.js FAQ.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do not use a proxy as an automatic workaround without considering access control. If a document is private, the proxy must enforce the authorization rules that protect it; otherwise it could unintentionally make private content available to other users. Check the browser console and network panel to distinguish a CORS denial from a bad URL, expired authorization, or missing file.

Large PDFs, page rendering, and memory

Rendering every page immediately is convenient for a short file, but each high-resolution page may require a substantial canvas. Many canvases together can consume significant memory and make a long document slow to load or scroll. PDF.js recommends rendering only visible pages to reduce memory use; consider virtualizing the page list or rendering the current page and nearby pages for long documents. See the PDF.js FAQ.

PDF.js can use HTTP Range Requests to fetch portions needed for visible pages when browser support and the server’s response headers allow it. This can avoid fetching an entire large file up front, but it depends on the server and response path; do not assume partial loading is working without checking network requests. If the file is slow, first determine whether the delay comes from transfer, document parsing, or rendering many pages.

Rank #4
PDF Viewer Plus, pdf reader
  • View pdf files
  • Merge Pdf files
  • Compress pdf files
  • Night mode
  • Snap to page

Viewing a PDF is different from generating one

react-pdf (React-PDF) is for displaying an existing PDF with PDF.js. @react-pdf/renderer is a separate library for creating PDFs from React components. The renderer’s advanced guide warns that generating documents with 30 or more pages directly in React can occupy the main thread and make the UI unresponsive, and suggests moving generation into a web worker. That is a document-generation warning, not a measured page limit or performance rule for viewing an existing PDF. See the renderer advanced guide.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Or skip the browser setup

If your goal is to capture a webpage as an image or PDF rather than embed an existing PDF for users to browse, ScreenshotNeo offers a website screenshot API and MCP server. It is not a replacement for a React PDF viewer: it captures a URL instead of giving your app interactive, page-by-page controls for an existing document.

One GET request can return a PNG, JPEG, WebP, or PDF. For example, this cURL call captures a webpage to WebP:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request options. Cookie banners, newsletter popups, and chat widgets are removed before capture; bot checks, blank pages, failed loads, and cache hits are not billed. Each response includes X-Page-Verdict and X-Billed headers. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up free for 1,000 screenshots a month with no card.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting React-PDF

Worker file cannot be found or loads as an error

Check that the worker path resolves in your bundler and that the worker file comes from the same PDF.js version used by React-PDF. Put the GlobalWorkerOptions.workerSrc assignment in the viewer module itself. If the build tool handles worker assets differently, use the setup documented for that tool and your installed version.

Best Value
PDF Reader For Fire Tablet & Ebook Reader, Viewer, Editor, Convertor, Merge, Split & Compress
  • Fast & Smooth PDF Reader – Open, view, and read PDF files with ease.
  • Dark Mode Support – Comfortable reading experience at night.
  • Quick Search & Bookmarking – Find text and save favorite pages instantly.
  • Annotate & Edit PDFs – Highlight, underline, and add comments.
  • Merge & Split PDFs – Combine or separate pages easily.

The PDF is blank or never finishes loading

Verify that the URL points to a real PDF, that it is reachable from the browser, and that any required authorization is included. Then inspect the network and console panels for a failed request, CORS error, or worker loading failure. If the request succeeds but pages stay blank, check that Document has loaded and that the Page components receive valid one-based page numbers.

The PDF works in an iframe but not in React-PDF

A native embed and a JavaScript fetch do not have identical cross-origin behavior. Configure CORS on the PDF host or use a carefully secured server proxy for the PDF.js request; an iframe working does not grant JavaScript access to the file.

Build or server-rendering errors

Confirm the React, Node.js, browser, and React-PDF requirements for the version you installed. For a Next.js application, isolate browser-dependent viewer code from server rendering if necessary. Ensure the bundler is set up to include the worker module rather than treating its path as an ordinary static string.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The page becomes sluggish on a long document

Avoid creating a canvas for every page at once. Render only the visible or nearby pages, and use range loading only where the browser and server support it. If the problem occurs while creating a PDF rather than viewing one, check whether the application is using @react-pdf/renderer; its generation guidance is separate from React-PDF viewing.

FAQ

Can I use a local PDF file selected by the user?

Yes. Pass a file value supported by React-PDF, such as a selected browser File object, to the file prop. For a native embed, a selected file generally needs a browser object URL rather than a filesystem path; revoke object URLs when they are no longer needed.

Does React-PDF provide a complete toolbar?

The examples here render document pages; a polished toolbar, zoom controls, download action, and navigation are interface choices you add around them. The separate PDF.js viewer layer is a fuller starting point, but Mozilla asks sites that embed it to reskin or build upon it.

Frequently Asked Questions

Can I embed a PDF that requires a login?

Only if the browser can obtain it with the required authorization. For React-PDF, use an authorized request or a server proxy that preserves access control; do not expose a private document through a public proxy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Does the 30-page warning apply to React-PDF viewing?

No. The 30-or-more-page caution cited above is for PDF generation with @react-pdf/renderer, not for displaying an existing PDF with React-PDF.

Quick Recap

Bestseller No. 1
PDF Reader for Fire Tablet
PDF Reader for Fire Tablet
PDF Reader for Fire Tablet; ✔Fast PDF Viewer; ✔Simple List of PDF Files; ✔Share and Print PDF
$2.99
Bestseller No. 2
PDF Reader, PDF Viewer, PDF Editor- file document
PDF Reader, PDF Viewer, PDF Editor- file document
PDF Reader; PDF Viewer; PDF Editor
$6.85
Bestseller No. 3
My PDF Reader
My PDF Reader
Open PDF files easily on your smartphone.; Cool User Interface and look.; Zoom and pan easily by using gesture with your fingers.
Bestseller No. 4
PDF Viewer Plus, pdf reader
PDF Viewer Plus, pdf reader
View pdf files; Merge Pdf files; Compress pdf files; Night mode; Snap to page; Horizontal View
Bestseller No. 5
PDF Reader For Fire Tablet & Ebook Reader, Viewer, Editor, Convertor, Merge, Split & Compress
PDF Reader For Fire Tablet & Ebook Reader, Viewer, Editor, Convertor, Merge, Split & Compress
Fast & Smooth PDF Reader – Open, view, and read PDF files with ease.; Dark Mode Support – Comfortable reading experience at night.
$2.99

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.