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. Answer from TotomInc on reddit.com
🌐
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.
🌐
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();
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
PDF displays on local machine but not when deployed
My resume (which is a pdf) will not display when deployed but it works fine when I run my react-app locally. The button I created in order to download the resume works fine but the resume itself is not shown on my “Resume” page. Instead on the left hand side it says “Failed to load file” ... More on answers.netlify.com
🌐 answers.netlify.com
1
0
August 7, 2023
Building my own UI doesn't work - no worker file
Which product are you using? PDF.js Express 8.3.0 Detailed description of issue I want to create my own UI with @pdftron/pdfjs-express (8.3.0) and integrate it with React (17.0.2). I followed this page, declared web… More on pdfjs.community
🌐 pdfjs.community
0
February 5, 2022
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
🌐
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.
🌐
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.cloudflare.com/ajax/libs/pdf.js/2.6.347/pdf_viewer.js.map ·
🌐
Mozilla
mozilla.github.io › pdf.js › getting_started
PDF.js - Getting Started
├── docs/ - website source ... package.json - package definition and dependencies · With the prebuilt or source version, open web/viewer.html in a browser and the test pdf should load. Note: the worker is not enabled for file:// urls, so use a server. If you're using the source build and have node, you can run npx gulp server. For a further walkthrough of a minimal viewer, see ...
🌐
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
🌐
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
Find elsewhere
🌐
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
🌐
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 › examples › keep-the-worker-version-in-sync-with-pdfjs-dist-version
Keep the worker version in sync with pdfjs-dist version - React PDF Viewer
import packageJson from '../package.json'; const pdfjsVersion = packageJson.dependencies['pdfjs-dist']; <Worker workerUrl={`https://unpkg.com/pdfjs-dist@${pdfjsVersion}/build/pdf.worker.min.js`}>...</Worker>; Compile and set the worker source with Webpack
🌐
Netlify
answers.netlify.com › support
PDF displays on local machine but not when deployed - Support - Netlify Support Forums
August 7, 2023 - My resume (which is a pdf) will not display when deployed but it works fine when I run my react-app locally. The button I created in order to download the resume works fine but the resume itself is not shown on my “Resume” page. Instead on the left hand side it says “Failed to load file” in small letters.
🌐
GitLab
gitlab.com › gitlab.org › merge requests › !170803
Update pdf worker file path in pdf viewer (!170803) · Merge requests · GitLab.org / GitLab · GitLab
October 28, 2024 - This MR updates to read the path from the environment variables and simplified the path for worker file to /assets/webpack/pdfjs/3.11.174/pdf.worker.min.js.
🌐
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. For most cases, the following example will work: import { pdfjs } from 'react-pdf'; pdfjs.GlobalWorkerOptions.workerSrc = new URL( 'pdfjs-dist/build/pdf.worker.min.mjs', import.meta.url, ).toString(); Warning ·
Starred by 10.7K users
Forked by 981 users
Languages   TypeScript 94.3% | CSS 5.6% | HTML 0.1%
🌐
PDF.js Express
pdfjs.community › technical support
Building my own UI doesn't work - no worker file - Technical Support - PDF.js Express
February 5, 2022 - Which product are you using? PDF.js Express 8.3.0 Detailed description of issue I want to create my own UI with @pdftron/pdfjs-express (8.3.0) and integrate it with React (17.0.2). I followed this page, declared webviewer-core.min.js script in index.html template.
🌐
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.
🌐
Greasy Fork
greasyfork.org › en › scripts › 388115-pdf-js-worker › code
PDF.js Worker - Source code
Date.now() : 0; page.getOperatorList({ handler: handler, task: task, intent: data.intent, renderInteractiveForms: data.renderInteractiveForms }).then(function (operatorList) { finishWorkerTask(task); if (start) { (0, _util.info)("page=".concat(pageIndex + 1, " - getOperatorList: time=") + "".concat(Date.now() - start, "ms, len=").concat(operatorList.totalLength)); } }, function (e) { finishWorkerTask(task); if (task.terminated) { return; } handler.send('UnsupportedFeature', { featureId: _util.UNSUPPORTED_FEATURES.unknown }); var minimumStackMessage = 'worker.js: while trying to getPage() and g
🌐
jsDelivr
jsdelivr.com › package › npm › vue-pdf-worker-fix
vue-pdf-worker-fix CDN by jsDelivr - A CDN for npm and GitHub
January 15, 2021 - vue.js pdf viewer - worker fix · Version 4.2.2 License MIT · Keywords · vue.jspdfviewerworker · INSTALL · Version: Static · Static · Latest Patch · Latest Minor · Latest Major · Learn more · Readme Files Statistics Browse CDN · Statistics · Requests 0 ·
Published   Jan 14, 2021
🌐
Skool
skool.com › universityofcode › solved-pdfjs-worker-optiosn-url-issue
SOLVED pdfjs worker optiosn url issue · University of Code
pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.min.js`;