Installation
Add LumiPDF to your React app with npm, yarn, or pnpm. Peer dependencies must be installed in your project.
Package
bash
npm install lumipdfbash
yarn add lumipdfbash
pnpm add lumipdfPeer dependencies
LumiPDF expects React 18+ and PDF.js. Install them if your project does not already include them:
bash
npm install react react-dom pdfjs-dist- react / react-dom ≥ 18
- pdfjs-dist ^4.7
Styles
Import the package stylesheet once in your app root (e.g. layout.tsx or main.tsx):
tsx
import "lumipdf/styles";PDF.js worker
By default the PDF.js worker can load from a CDN (jsDelivr). For self-hosted workers, set GlobalWorkerOptions.workerSrc before rendering:
tsx
import * as pdfjsLib from "pdfjs-dist";
pdfjsLib.GlobalWorkerOptions.workerSrc = new URL(
"pdfjs-dist/build/pdf.worker.min.mjs",
import.meta.url,
).toString();CORS
Remote PDF URLs must allow cross-origin access from your app origin. Prefer same-origin assets or a proxy when the host does not send CORS headers.
Checklist
- Install lumipdf and peers
- Import lumipdf/styles
- Optionally configure the PDF.js worker
- Continue to Quick start