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
🌐
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...
🌐
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.
Discussions

Can't resolve 'pdfjs-dist/build/pdf.worker.min.mjs in Nextjs 14 app router
Before you start - checklist I followed instructions in documentation written for my React-PDF version I have checked if this bug is not already reported I have checked if an issue is not listed in Known issues If I have a problem with P... More on github.com
🌐 github.com
17
August 13, 2024
How do I solve this issue: Error: Setting up fake worker failed: "Cannot find module '/pdf.worker.js' ?
Are you using react-pdf into a Next.js app? 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(); If not using react-pdf, I assume it should still work as the GlobalWorkerOptions is an option object available from pdfjs. More on reddit.com
🌐 r/nextjs
23
7
August 3, 2023
🌐
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
🌐
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 ...
🌐
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
July 14, 2024 - Generic build of PDF.js library. . Contribute to mozilla/pdfjs-dist development by creating an account on GitHub.
Author   mozilla
🌐
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 │ └── ...
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.
For React-PDF to work, PDF.js worker needs to be provided. You have several options. ... import { pdfjs } from 'react-pdf'; pdfjs.GlobalWorkerOptions.workerSrc = new URL( 'pdfjs-dist/build/pdf.worker.min.mjs', import.meta.url, ).toString();
Starred by 10.7K users
Forked by 981 users
Languages   TypeScript 94.3% | CSS 5.6% | HTML 0.1%
🌐
SourceForge
sourceforge.net › projects › pdf-js.mirror
PDF.js download | SourceForge.net
November 2, 2025 - 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.
🌐
GitHub
github.com › wojtekmaj › react-pdf › issues › 1855
Can't resolve 'pdfjs-dist/build/pdf.worker.min.mjs in Nextjs 14 app router · Issue #1855 · wojtekmaj/react-pdf
August 13, 2024 - If I have a problem with PDF rendering, I checked if my PDF renders properly in PDF.js demo · import { Box, CircularProgress, Pagination, Stack, Typography } from '@mui/material'; import React, { useState } from 'react'; import { DocumentText } from 'iconsax-react'; import 'react-pdf/dist/esm/Page/AnnotationLayer.css'; import 'react-pdf/dist/esm/Page/TextLayer.css'; import { Document, Page, pdfjs } from 'react-pdf'; pdfjs.GlobalWorkerOptions.workerSrc = new URL('pdfjs-dist/build/pdf.worker.min.mjs', import.meta.url).toString(); const options = { cMapUrl: '/cmaps/', standardFontDataUrl: '/stan
Published   Aug 13, 2024
🌐
UNPKG
unpkg.com › pdfjs-dist
pdfjs-dist
Generic build of Mozilla's PDF.js library.
🌐
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.
🌐
npm
npmjs.com › package › pdfjs-dist
pdfjs-dist - npm
2 weeks ago - Generic build of Mozilla's PDF.js library.. Latest version: 5.4.449, last published: 12 days ago. Start using pdfjs-dist in your project by running `npm i pdfjs-dist`. There are 2279 other projects in the npm registry using pdfjs-dist.
      » npm install pdfjs-dist
    
Published   Nov 29, 2025
Version   5.4.449
🌐
Snyk
snyk.io › advisor › pdfjs-dist › functions › pdfjs-dist.globalworkeroptions
How to use the pdfjs-dist.GlobalWorkerOptions function in pdfjs-dist | Snyk
import * as React from "react"; import * as CSSModules from "react-css-modules"; import * as styles from "./index.less"; import * as pdfjsLib from "pdfjs-dist"; const pdfjsViewer = require("../../../node_modules/pdfjs-dist/web/pdf_viewer.js"); // The workerSrc property shall be specified. pdfjsLib.GlobalWorkerOptions.workerSrc = "https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.0.550/pdf.worker.js"; // default scale const DEFAULT_MIN_SCALE = 0.25; const DEFAULT_MAX_SCALE = 10.0; let USE_ONLY_CSS_ZOOM = true; let TEXT_LAYER_MODE = 0; // DISABLE let MAX_IMAGE_SIZE = 1024 * 1024; let CMAP_PACKED = true; let DEFAULT_URL = "/test.pdf"; let DEFAULT_SCALE_DELTA = 1.1; let MIN_SCALE = DEFAULT_MIN_SCALE; let MAX_SCALE = DEFAULT_MAX_SCALE; let DEFAULT_SCALE_VALUE: string|number = "auto"; // in order to be responsive interface IProps { url: string|object; page?: number|string; scale?: number|string;
🌐
jsDelivr
jsdelivr.com › package › npm › pdfjs-dist
pdfjs-dist CDN by jsDelivr - A CDN for npm and GitHub
September 22, 2014 - Mozillapdfpdf.js · 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 pdfjs-dist Download Stats · Share · Keywords ·
Published   Sep 22, 2014
🌐
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 ...
🌐
GitHub
github.com › mozilla › pdf.js
GitHub - mozilla/pdf.js: PDF Reader in JavaScript
This will generate pdf.js and pdf.worker.js in the build/generic/build/ directory (respectively build/generic-legacy/build/). Both scripts are needed but only pdf.js needs to be included since pdf.worker.js will be loaded by pdf.js. The PDF.js files are large and should be minified for production.
Starred by 52.4K users
Forked by 10.5K users
Languages   JavaScript 71.3% | Fluent 25.5% | CSS 2.2%
🌐
Mozilla
mozilla.github.io › pdf.js
PDF.js - Home
A general-purpose, web standards-based platform for parsing and rendering PDFs.