npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

hive-react-document-viewer

v0.1.3

Published

A powerful React component for viewing **PDF**, **DOCX**, and **PPTX** documents. Features include thumbnail navigation, text search, zoom controls, fullscreen mode, and optional OCR support for scanned documents.

Readme

Hive React Document Viewer

A powerful React component for viewing PDF, DOCX, and PPTX documents. Features include thumbnail navigation, text search, zoom controls, fullscreen mode, and optional OCR support for scanned documents.

npm version License: MIT

Features

  • 📄 PDF viewing with high-fidelity rendering
  • 📑 Thumbnail sidebar with page navigation
  • 🔍 Text search with match highlighting
  • 🔎 Zoom controls (fit to page, zoom in/out)
  • 📥 Download & Print support
  • 🖥️ Fullscreen mode
  • 📝 DOCX support (rendered as HTML)
  • 📊 PPTX support (via PDF conversion)
  • 🔤 OCR support for scanned PDFs (via Tesseract.js)
  • 🎨 Customizable theming

Installation

npm install hive-react-document-viewer

Peer dependencies: react and react-dom (>=16.8.0)

Quick Start

import { DocumentViewer } from "hive-react-document-viewer";

function App() {
  return (
    <div style={{ height: "100vh" }}>
      <DocumentViewer
        src="/path/to/document.pdf"
        mimeType="application/pdf"
      />
    </div>
  );
}

Usage Examples

Basic PDF Viewer

<DocumentViewer src="https://example.com/document.pdf" />

With Options

<DocumentViewer
  src={fileUrl}
  mimeType="application/pdf"
  options={{
    showToolbar: true,
    showSidebar: true,
    sidebarMode: "thumbnails",
    resolutionScale: 2,
    zoom: 1,
  }}
/>

With Viewer API

import { DocumentViewer, PdfViewerApi } from "hive-react-document-viewer";

function App() {
  const [viewerApi, setViewerApi] = useState<PdfViewerApi | null>(null);

  return (
    <>
      <button onClick={() => viewerApi?.scrollToPage(5)}>Go to Page 5</button>
      <DocumentViewer
        src="/document.pdf"
        options={{
          onViewerReady: setViewerApi,
        }}
      />
    </>
  );
}

File Upload

function App() {
  const [file, setFile] = useState<File | null>(null);

  return (
    <>
      <input
        type="file"
        accept=".pdf,.docx,.pptx"
        onChange={(e) => setFile(e.target.files?.[0] ?? null)}
      />
      {file && <DocumentViewer src={file} />}
    </>
  );
}

Office Documents (DOCX/PPTX)

For DOCX/PPTX files, you can either render DOCX as HTML directly, or convert to PDF using a conversion endpoint:

<DocumentViewer
  src={officeFile}
  options={{
    conversionWorkerUrl: "https://your-api.com/convert",
  }}
  onConversionError={(err) => console.error("Conversion failed:", err)}
/>

Props

| Prop | Type | Description | |------|------|-------------| | src | string \| Blob \| File | Document URL or file object | | mimeType | string | MIME type (auto-detected if omitted) | | options | ViewerOptions | Viewer configuration options | | theme | ViewerTheme | Theme customization | | onRetry | () => void | Retry callback (shows retry button on error) | | onConversionError | (error: Error) => void | Called when Office conversion fails | | className | string | Additional CSS class | | style | CSSProperties | Inline styles |

ViewerOptions

| Option | Type | Default | Description | |--------|------|---------|-------------| | showToolbar | boolean | true | Show the toolbar | | showSidebar | boolean | true | Show the thumbnail sidebar | | sidebarMode | "none" \| "thumbnails" \| "outline" \| "both" | "thumbnails" | Sidebar content | | showSearch | boolean | true | Show search in toolbar | | showPrint | boolean | true | Show print button | | showFullscreen | boolean | true | Show fullscreen button | | zoom | number | 1 | Zoom level multiplier | | resolutionScale | number | 1 | Canvas resolution scale (higher = sharper) | | enableOCR | boolean | false | Enable OCR for scanned PDFs | | conversionWorkerUrl | string | - | URL for Office→PDF conversion | | viewerBackgroundColor | string | #525659 | Viewer background color | | pageBackgroundColor | string | #ffffff | Page background color | | toolbarBackgroundColor | string | - | Toolbar background color | | onViewerReady | (api: PdfViewerApi) => void | - | Callback with viewer API | | onDownload | (src, mime) => void | - | Custom download handler | | onPrint | (src, mime) => void | - | Custom print handler | | onFullscreen | (el) => void | - | Custom fullscreen handler | | downloadFileName | string | - | Custom download filename |

Viewer API

The onViewerReady callback provides an API to control the viewer programmatically:

interface PdfViewerApi {
  scrollToPage: (page: number) => void;
  nextMatch: () => void;
  prevMatch: () => void;
}

Exports

import {
  DocumentViewer,
  PdfToolbar,
  registerRenderer,
  getRenderer,
  listRenderers,
  type PdfViewerApi,
  type PdfToolbarProps,
  type ViewerOptions,
  type ViewerTheme,
} from "hive-react-document-viewer";

PDF.js Worker Setup

For optimal PDF rendering, serve the bundled PDF.js worker at /pdf.worker.js:

# Copy from node_modules after install
cp node_modules/hive-react-document-viewer/dist/pdf.worker.js public/pdf.worker.js

The package runs a postinstall script that patches PDF.js for better image quality.

Conversion Worker

For DOCX/PPTX files, provide a conversion endpoint that accepts:

  • Request: POST with multipart/form-data, field file
  • Response: Either raw PDF bytes (Content-Type: application/pdf) or JSON { "url": "..." }

Theming

<DocumentViewer
  src={file}
  theme={{
    primary: "#1a1a2e",
    textPrimary: "#ffffff",
  }}
/>

CSS Classes

Style the viewer using these CSS classes:

  • .document-viewer - Main container
  • .document-viewer-loading - Loading state
  • .document-viewer-error - Error state
  • .document-viewer-search-hit - Search match highlight
  • .document-viewer-search-hit-active - Active search match

Browser Support

  • Chrome (recommended)
  • Firefox
  • Safari
  • Edge

License

MIT