A React PDF reader powered by Rust/WASM with theming support
npm install rusty-pdfA lightweight React PDF viewer powered by Rust/WASM with theming support.


- 📄 Rust-Powered PDF Rendering - Fast PDF display via WebAssembly
- 🎨 Theme Support - Light, dark, or system preference modes
- 📱 Simple Navigation - Built-in page controls and download button
- ⚡ Lightweight - Only 66KB unpacked
---
``bash`
npm install rusty-pdf
---
`jsx
import RustyPdf from 'rusty-pdf';
import 'rusty-pdf/styles.css';
function App() {
return (
theme="system"
/>
);
}
`
---
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| url | string | required | URL of the PDF file to display |theme
| | 'light' \| 'dark' \| 'system' | 'system' | Theme mode for the viewer |
---
The viewer supports three theme modes:
| Theme | Description |
|-------|-------------|
| light | Light background with dark text |dark
| | Dark background with light text |system
| | Automatically matches OS preference |
`jsx
// Force light mode
// Force dark mode
// Follow system preference (default)
`
---
The viewer includes a toolbar with:
| Control | Description |
|---------|-------------|
| ‹ | Previous page |
| Page indicator | Shows current page / total pages |
| › | Next page |
| ↓ | Download PDF |
---
Import the included stylesheet:
`jsx`
import 'rusty-pdf/styles.css';
Or customize by targeting these CSS classes:
`css`
.pdf-wrapper { } / Main container /
.pdf-toolbar { } / Navigation bar /
.pdf-loading { } / Loading spinner container /
.pdf-spinner { } / Loading animation /
.canvas-container { } / PDF canvas wrapper /
.pdf-footer { } / Footer with credits /
.pdf-light { } / Light theme /
.pdf-dark { } / Dark theme /
---
`jsx
import React from 'react';
import RustyPdf from 'rusty-pdf';
import 'rusty-pdf/styles.css';
function PDFViewer() {
return (
export default PDFViewer;
``
---
- React 16.8.0 or higher
- Modern browser with WebAssembly support
---
This package uses Rust compiled to WebAssembly to power the PDF rendering engine. The WASM module handles:
1. PDF Parsing - Loading and parsing PDF file structure
2. Page Rendering - Drawing pages to an HTML canvas
3. File Operations - Downloading the PDF file
---
Upcoming features planned for future releases:
| Feature | Description | Status |
|---------|-------------|--------|
| 🔍 Text Search | Search for text within PDFs with highlighting | Planned |
| 🖍️ Highlights | Select and highlight text with multiple colors | Planned |
| 📝 Sticky Notes | Add notes to selected text | Planned |
| 💾 Annotations Persistence | Save/load highlights and notes via callbacks | Planned |
| 🔎 Zoom Controls | Zoom in/out functionality | Planned |
---
MIT © codeninja-404