Install the package
svelte-pdf-mini targets Svelte 5.57+ (runes, attachments) and the latest evergreen browsers. It depends on pdfjs-dist 6, runed and svelte-toolbelt. @cantoo/pdf-lib (PDF export) and KaTeX / marked (Markdown notes) are loaded lazily on first use. See Bundlers & deployment for exact requirements, non-Vite bundlers, CORS and CSP.
Configure Vite
Keep pdfjs-dist out of Vite’s dependency pre-bundling. Without it, vite dev fails to load the pdf.js worker (why):
Import the styles (optional)
With Tailwind v4, import it from your CSS and declare the layer order in your HTML <head> (@layer theme, base, svelte-pdf-mini, components, utilities;), see Styling. The stylesheet holds the pdf.js text-layer rules, focus effects and calm defaults for the floating UI (menus, popovers, cards, side notes, tables of contents). Every value is a CSS variable; skip it entirely if you style the parts yourself.
Worker and assets
pdf.js runs in a Web Worker. With Vite the worker is set up automatically and shared by every document on the page. Character maps, standard fonts and the WASM decoders load from jsDelivr by default; to self-host them, call configurePdf once, before the first document loads:
Copy the folders from node_modules/pdfjs-dist/ into your static/ directory. configurePdf also accepts workerSrc, workerPort (a ready Worker to use instead), documentOptions (merged into every getDocument() call), sharedWorker: false and bitmapCacheBytes (memory for off-screen page bitmaps, default 192 MB).
Server-side rendering
Components render their static shell on the server and only start loading documents in the browser, after hydration. No special setup is needed in SvelteKit, and prerendering works. See SSR and prerendering.