Install pdfjs-dist

import { Document, Page, pdfjs } from "react-pdf";
import pdfjsWorker from "pdfjs-dist/build/pdf.worker.entry";

pdfjs.GlobalWorkerOptions.workerSrc = pdfjsWorker;

Reference: https://github.com/mozilla/pdf.js/issues/8305

UPDATE

react-pdf >= 9.0.0

import { Document, Page, pdfjs } from "react-pdf";
import { WorkerMessageHandler } from "pdfjs-dist/build/pdf.worker.min.mjs";

pdfjs.GlobalWorkerOptions.workerSrc = new URL(
  WorkerMessageHandler,
  import.meta.url
).toString();

This also fixed a known issue:

Failed to load module script: Expected a JavaScript-or-Wasm module script but the server responded with a MIME type of "application/octet-stream". Strict MIME type checking is enforced for module scripts per HTML spec.

https://github.com/wojtekmaj/react-pdf/issues/1825

Answer from lissettdm on Stack Overflow
🌐
Mozilla
mozilla.github.io › pdf.js › getting_started
PDF.js - Getting Started
$ git clone https://github.com/mozilla/pdf.js.git $ cd pdf.js ... Note that we only mention the most relevant files and folders. ├── build/ │ ├── pdf.mjs - display layer │ ├── pdf.mjs.map - display layer's source map │ ├── pdf.worker.mjs - core layer │ └── ...
🌐
GitHub
github.com › mozilla › pdf.js
GitHub - mozilla/pdf.js: PDF Reader in JavaScript
PDF Reader in JavaScript. Contribute to mozilla/pdf.js development by creating an account on GitHub.
Starred by 52.4K users
Forked by 10.5K users
Languages   JavaScript 71.3% | Fluent 25.5% | CSS 2.2%
🌐
GitHub
github.com › mozilla › pdfjs-dist › blob › master › build › pdf.worker.js.map
pdfjs-dist/build/pdf.worker.js.map at master · mozilla/pdfjs-dist
Generic build of PDF.js library. . Contribute to mozilla/pdfjs-dist development by creating an account on GitHub.
Author   mozilla
🌐
GitHub
gist.github.com › Katerinka28 › 09f3496710c2dac7b3fe3335ae4d81a0
pdf.worker.js · GitHub
Clone this repository at <script src="https://gist.github.com/Katerinka28/09f3496710c2dac7b3fe3335ae4d81a0.js"></script> Save Katerinka28/09f3496710c2dac7b3fe3335ae4d81a0 to your computer and use it in GitHub Desktop. Download ZIP · pdf.worker.js ·
🌐
SourceForge
sourceforge.net › projects › pdf-js.mirror
PDF.js download | SourceForge.net
Download PDF.js for free. A PDF Reader in JavaScript. PDF.js is a web standards-based platform for parsing and rendering Portable Document Formats (PDFs). Open source and built with HTML5, this PDF viewer is supported by a great community and Mozilla Labs.
🌐
Quora
quora.com › How-can-I-download-a-PDF-file-that-is-rendered-by-PDF-js-and-doesnt-have-a-download-button
How to download a PDF file that is rendered by PDF.js and doesn't have a download button - Quora
Answer: Well, I don’t know anything about PDF.js, and I understand one of those files may behave differently, but I’ll give you methods that would work on an ordinary pdf. Maybe they’ll work for you. I’m assuming you’re looking at it in a web browser, and probably got to it by a link ...
🌐
jsDelivr
jsdelivr.com › package › npm › pdf.worker
pdf.worker CDN by jsDelivr - A CDN for npm and GitHub
October 10, 2023 - This is a required file for pdf js to work · Version 1.0.0 License ISC · INSTALL · Version: Static · Static · Latest Patch · Latest Minor · Latest Major · Learn more · Readme Files Statistics Browse CDN · Statistics · Requests 0 · Bandwidth 0 · Top version - 0 Full pdf.worker Download Stats ·
Published   Oct 10, 2023
Find elsewhere
🌐
Mozilla
mozilla.github.io › pdf.js › examples
PDF.js - Examples
This tutorial shows how PDF.js can be used as a library in a web browser.
🌐
Google Groups
groups.google.com › g › mozilla.dev.pdf-js › c › 8B6iCsj5Hkg
pdf.worker.js and other js files make for a large client download
On 9/26/14, 1:59 PM, [email protected] wrote: > It looks like the pdf.js files add up to about 1.5 MB that the browser needs to download. This is very large and will cause a delay for the user. > > I am missing something or are there steps that can help this? 1. You can run minifier: google closure worked for us, other had some issues. See https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#minified. 2. If you know that some functionality is not used in your PDFs, e.g. JBIG2, JPX, some font types, you can build your own pdf.worker.js with only functionality you need.
🌐
cdnjs
cdnjs.com › home › libraries › pdf.js › 2.6.347
pdf.js - Libraries - cdnjs - The #1 free and open source CDN built to make life easier for developers
https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.6.347/pdf.worker.min.js · https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.6.347/pdf_viewer.css · https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.6.347/pdf_viewer.js · https://cdnjs.cloudfla...
🌐
React PDF Viewer
react-pdf-viewer.dev › docs › basic-usage
Basic usage - React PDF Viewer
https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.4.120/pdf.worker.min.js · or download and store it on your server. Note · It's very important to note that the worker version and the `pdfjs` package (mentioned in the Install pdfjs library section of Getting started) have to be the same.
🌐
npm
npmjs.com › package › pdfjs-dist
pdfjs-dist - npm
Generic build of Mozilla's PDF.js library.. Latest version: 5.4.449, last published: 14 days ago. Start using pdfjs-dist in your project by running `npm i pdfjs-dist`. There are 2281 other projects in the npm registry using pdfjs-dist.
      » npm install pdfjs-dist
    
Published   Nov 29, 2025
Version   5.4.449
🌐
UNPKG
unpkg.com [email protected] › build
UNPKG
Generic build of Mozilla's PDF.js library.
🌐
SourceForge
sourceforge.net › home › open source software › formats and protocols › protocols › web services › pdf.js › files
PDF.js - Browse Files at SourceForge.net
This is an exact mirror of the PDF.js project, hosted at https://github.com/mozilla/pdf.js. SourceForge is not affiliated with PDF.js. For more information, see the SourceForge Open Source Mirror Directory. Summary · Files · Reviews · Download Latest Version pdfjs-5.4.449-dist.zip (6.4 MB) Home ·
🌐
CDNPKG
cdnpkg.com › home › pdf.js › pdf.worker.min.js
PDF.WORKER.MIN.JS: DOWNLOAD - CDNPKG
Download pdf.worker.min.js or get a CDN url for 1510 versions of pdf.js.
🌐
Mozilla
mozilla.github.io › pdf.js
PDF.js - Home
A general-purpose, web standards-based platform for parsing and rendering PDFs.
🌐
Nutrient
nutrient.io › blog › sdk › complete guide to pdfjs
Complete guide to PDF.js
August 11, 2025 - Download or clone PDF.js — You can download(opens in a new tab) the library as a ZIP file or clone the repository using Git. Prepare the files — Extract the ZIP file and copy the pdf.mjs and pdf.worker.mjs files from the build/ folder to ...