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 │ └── ...
🌐
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.
🌐
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 ·
🌐
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
🌐
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...
🌐
npm
npmjs.com › package › pdfjs-dist
pdfjs-dist - npm
Generic build of Mozilla's PDF.js library.. Latest version: 5.4.449, last published: 18 days ago. Start using pdfjs-dist in your project by running `npm i pdfjs-dist`. There are 2286 other projects in the npm registry using pdfjs-dist.
      » npm install pdfjs-dist
    
Published   Nov 29, 2025
Version   5.4.449
🌐
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.
🌐
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.
🌐
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.5K users
Forked by 10.5K users
Languages   JavaScript 71.1% | Fluent 25.5% | CSS 2.3% | HTML 1.1%
🌐
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.
🌐
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.
🌐
Mozilla
mozilla.github.io › pdf.js
PDF.js - Home
A general-purpose, web standards-based platform for parsing and rendering PDFs.
🌐
Reddit
reddit.com › r/nextjs › how do i solve this issue: error: setting up fake worker failed: "cannot find module '/pdf.worker.js' ?
r/nextjs on Reddit: How do I solve this issue: Error: Setting up fake worker failed: "Cannot find module '/pdf.worker.js' ?
August 3, 2023 - React-pdf uses under the hood pdfjs, and you should follow their configuration instructions in order to properly make it work for Next.js: import { pdfjs } from 'react-pdf'; pdfjs.GlobalWorkerOptions.workerSrc = new URL( 'pdfjs-dist/build/pdf.worker.min.js', import.meta.url, ).toString();
🌐
GitHub
github.com › wojtekmaj › react-pdf
GitHub - wojtekmaj/react-pdf: Display PDFs in your React app as easily as if they were images.
For React-PDF to work, PDF.js worker needs to be provided.
Starred by 10.7K users
Forked by 983 users
Languages   TypeScript 94.3% | CSS 5.6% | HTML 0.1%
🌐
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 ·