Installation

Add LumiPDF to your React app with npm, yarn, or pnpm. Peer dependencies must be installed in your project.

Package

bash
npm install lumipdf
bash
yarn add lumipdf
bash
pnpm add lumipdf

Peer 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

  1. Install lumipdf and peers
  2. Import lumipdf/styles
  3. Optionally configure the PDF.js worker
  4. Continue to Quick start