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

@rozie-ui/pdf-react

v0.2.1

Published

Idiomatic React PDF viewer wrapping PDF.js — one Rozie source compiled to React.

Readme

@rozie-ui/pdf-react

Idiomatic react PdfViewer — a cross-framework PDF viewer compiled from one Rozie source wrapping PDF.js (pdfjs-dist). The current page is two-way bound via page (1-based), with selectable text, zoom and rotation. This package is generated; do not edit src/ by hand.

Install

npm i @rozie-ui/pdf-react

Peer dependencies: the pdfjs-dist engine (^6) + react + react-dom. Install them alongside this package.

No separate engine-CSS import is needed — PdfViewer ships the selectable text-layer CSS itself. The PDF.js worker is auto-configured from a version-matched CDN, so the component works with zero config; override the workerSrc prop for offline / CSP / bundled-worker setups.

Usage

import { useState } from 'react';
import { PdfViewer } from '@rozie-ui/pdf-react';

export function Demo() {
  const [page, setPage] = useState(1);
  return (
    <PdfViewer
      src="/document.pdf"
      page={page}
      onPageChange={(e) => setPage(e.page)}
      scale={1.2}
      render-all-pages
      onLoad={(e) => console.log(e.numPages)}
    />
  );
}

Props

| Name | Type | Default | Two-way (model) | Required | | --- | --- | --- | :---: | :---: | | src | unknown | undefined | | | | page | Number | 1 | ✓ | | | scale | Number | 1 | | | | rotation | Number | 0 | | | | workerSrc | String | undefined | | | | standardFontDataUrl | String | undefined | | | | renderAllPages | Boolean | false | | | | textLayer | Boolean | true | | | | password | unknown | undefined | | | | query | unknown | undefined | | | | autoFit | unknown | undefined | | | | options | Object | {} | | |

Events

| Event | Description | | --- | --- | | pagerendered | | | error | | | pagesrendered | | | passwordrequest | | | progress | | | load | | | pagechange | | | findresult | |

Imperative handle

Beyond props, the component exposes imperative methods (declared once in the Rozie source via $expose). Grab a handle with the native ref mechanism and call them directly:

import { useRef } from 'react';
import { PdfViewer, type PdfViewerHandle } from '@rozie-ui/pdf-react';

const viewer = useRef<PdfViewerHandle>(null);
// <PdfViewer ref={viewer} ... />
viewer.current?.nextPage();
const total = viewer.current?.getPageCount();

| Method | Description | | --- | --- | | getDocument | Return the underlying pdfjs PDFDocumentProxy for direct API access (the engine escape hatch), or null before the document loads. | | getPageCount | Return the total number of pages in the loaded document, or 0 before it loads. | | goToPage | Navigate to a 1-based page (clamped to [1, pageCount]) — goToPage(n). | | nextPage | Advance to the next page (clamped at the last page). | | prevPage | Go back to the previous page (clamped at the first page). | | setScale | Set the zoom scale to an absolute value (1 = 100%) — setScale(s). | | zoomIn | Zoom in by one step (×1.25, capped at 10×). | | zoomOut | Zoom out by one step (÷1.25, floored at 0.1×). | | fitWidth | Fit the current page to the container width. | | fitPage | Fit the current page entirely within the container (width and height). | | rotateCW | Rotate the view 90° clockwise. | | rotateCCW | Rotate the view 90° counter-clockwise. | | download | Download the original PDF bytes — download(filename?) (defaults to document.pdf). Resolves true on success, false before the document loads. | | getMetadata | Resolve the document metadata (title, author, page labels, …) — pdfjs PDFDocumentProxy.getMetadata(). null before load. | | getOutline | Resolve the document outline (bookmark / table-of-contents tree) for a navigation sidebar — pdfjs getOutline(). null when absent or before load. | | getPageElement | Return the rendered page's DOM node (.rozie-pdf-page[data-page]) — getPageElement(pageNumber) — the documented mount point for a consumer overlay, or null if that page isn't currently rendered. Paired with the pagerendered event for reactive per-page geometry; NOT stable across zoom/rotation/mode changes, so re-acquire it on every pagerendered firing rather than caching the node. | | find | Search the whole document for a query — find(query). Scans every page's text, navigates to + highlights the first match, returns a Promise resolving to the match count, and emits findresult. The highlight is coarse / span-level: it highlights whole text-layer spans that contain the query — a query straddling two spans won't highlight. | | findNext | Advance to the next match (wraps around), navigating its page + re-emitting findresult with the new current. No-op before a find. | | findPrev | Go back to the previous match (wraps around), navigating its page + re-emitting findresult. No-op before a find. | | clearFind | Clear the active query + highlights, re-render, and emit findresult with { query: '', matches: 0, current: 0 }. |