Appearance
PDF.js Plugin ​
File Information ​
- Path:
app/plugins/pdfjs.client.ts - Purpose: Client-only initialization of the PDF.js worker so the application has a single, global worker path for all PDF rendering
- Client-only: Yes (
.client.tssuffix); no-op on server
Overview ​
The plugin ensures the PDF.js worker is configured once for the entire application. It calls usePdfJs() (which lazily imports and caches the PDF.js library) and sets GlobalWorkerOptions.workerSrc to /pdfjs/pdf.worker.min.mjs if not already set. This avoids duplicate worker registration and private field errors when multiple components use PDF.js.
Behavior ​
- Runs only in the browser (
import.meta.client). - Uses the shared usePdfJs composable to get the PDF.js instance.
- Worker file is expected at
public/pdfjs/pdf.worker.min.mjs(or equivalent build output).
Related ​
- usePdfJs - Shared PDF.js instance
- usePdfJsViewer - Viewer logic
- Components - PdfJsViewer
- Server API - PDF proxy - Cross-origin PDF loading