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

@anaralabs/lector

v3.15.3

Published

A headless PDF viewer for React

Downloads

90,084

Readme

Lector

A headless PDF viewer for React. Compose pages, text selection, search, and annotations into your own reading experience. Lector handles PDF.js rendering and page virtualization; you control the layout and UI.

Documentation · Live demo · npm · Contributing

Get a PDF on screen

Use React 19+. The current source expects pdfjs-dist ^5.5.207. These docs track main; check the releases against your installed package version.

npm install @anaralabs/lector pdfjs-dist@^5.5.207

Copy the PDF.js worker from your app's installed dependency to its public assets. Recopy it whenever you update PDF.js so the runtime and worker versions match.

mkdir -p public/pdfjs
cp node_modules/pdfjs-dist/legacy/build/pdf.worker.min.mjs public/pdfjs/

Put a PDF at public/sample.pdf, then add this browser-rendered component:

import { CanvasLayer, Page, Pages, Root, TextLayer } from "@anaralabs/lector";
import { GlobalWorkerOptions } from "pdfjs-dist/legacy/build/pdf.mjs";
import "pdfjs-dist/web/pdf_viewer.css";

GlobalWorkerOptions.workerSrc = "/pdfjs/pdf.worker.min.mjs";

export default function PDFViewer() {
  return (
    <Root
      source="/sample.pdf"
      style={{ height: 600 }}
      loader={<p role="status">Loading PDF…</p>}
    >
      <Pages>
        <Page>
          <CanvasLayer />
          <TextLayer />
        </Page>
      </Pages>
    </Root>
  );
}

For Next.js, load the viewer through a Client Component using dynamic(..., { ssr: false }); keep PDF.js setup inside the dynamically loaded module. See installation for the full wrapper, Vite worker setup, and deployments below a path prefix.

Root loads the document and provides its state. Pages owns scrolling and clones one Page template for visible pages. CanvasLayer paints the PDF; TextLayer adds selectable text. Give the viewer a definite height and import the PDF.js stylesheet so its layers align.

Build the reader your app needs

| Feature | Start here | | --- | --- | | Toolbar, page input, and layout | Your first viewer | | Authenticated URLs, local files, errors, and self-hosted assets | Loading documents | | Page navigation and fit width | Navigation, zoom | | Page previews | Thumbnails | | Text search and highlighted results | Search | | Selection and citation regions | Selection, highlights | | PDF links and editable form fields | Links, forms | | Dark page rendering | Dark mode | | Props, hooks, and defaults | API reference |

Lector is a toolkit rather than a finished toolbar or a PDF editor. Your app supplies accessible controls, error UI, and storage for user annotations. Search requires embedded text; it does not perform OCR. Custom highlight overlays do not automatically modify the PDF file. See troubleshooting for worker errors, blank pages, and layout issues.

Use with a coding assistant

Connect an MCP client to https://anara.com/lector/mcp using Streamable HTTP, with no API key. It can search and read every guide through tools and resources. See AI agents and MCP for setup and example requests.

For direct fetching, start with llms.txt, read individual Markdown guides, or use the complete documentation. These exports are generated from the same source as the website.

Work on Lector

From the repository root, with Node.js 22.13+ and pnpm 9.5.0:

pnpm install --frozen-lockfile
pnpm --filter @anaralabs/lector build
pnpm --filter docs dev

Open localhost:3000/docs. The docs app uses the local workspace package. For watch mode, validation commands, and testing in another application, read CONTRIBUTING.md.

Acknowledgements

Inspired by react-pdf-headless and pdfreader. Built on PDF.js and React.

License

MIT © Anara