# Build a PDF viewer with Lector

Start with a readable document, then add the controls your app needs.

Source: https://anara.com/lector/docs

These docs describe the source deployed with this site, tracking main rather than a versioned npm release. Check your installed @anaralabs/lector and pdfjs-dist versions before applying examples.

Lector is a headless PDF viewer for React. PDF.js loads and renders the document; Lector provides page virtualization, composable layers, and hooks for navigation, search, and selection. You own the toolbar, layout, and application state.

## Start here

1. [Install Lector](https://anara.com/lector/docs/installation) and configure the PDF.js worker.
2. [Build your first viewer](https://anara.com/lector/docs/basic-usage) with selectable text, a toolbar, and a visible loading state.
3. [Load your own documents](https://anara.com/lector/docs/document-loading), including authenticated URLs and local files.

Already integrating Lector? Keep the [API reference](https://anara.com/lector/docs/api) and [troubleshooting guide](https://anara.com/lector/docs/troubleshooting) nearby.

## Add a feature

| I want to…                                  | Guide                                                                 |
| ------------------------------------------- | --------------------------------------------------------------------- |
| See a minimal viewer running                | [Basic example](https://anara.com/lector/docs/code/basic)             |
| Go to a page or build previous/next buttons | [Page navigation](https://anara.com/lector/docs/code/page-navigation) |
| Fit a document to its container             | [Zoom controls](https://anara.com/lector/docs/code/zoom-control)      |
| Navigate using page previews                | [Thumbnails](https://anara.com/lector/docs/code/thumbnails)           |
| Find text and jump to a match               | [Search](https://anara.com/lector/docs/code/search)                   |
| Draw a citation or a saved region           | [Highlights](https://anara.com/lector/docs/code/highlight)            |
| Capture selected text and its coordinates   | [Text selection](https://anara.com/lector/docs/code/select)           |
| Enable links inside a PDF                   | [PDF links](https://anara.com/lector/docs/code/links)                 |
| Fill and download a PDF form                | [PDF forms](https://anara.com/lector/docs/code/pdf-form)              |
| Render light text on dark paper             | [Dark mode](https://anara.com/lector/docs/dark-mode)                  |

## What your application supplies

Lector supplies primitives, not a finished reader. Give the viewer a bounded height, label its controls, and decide how to handle errors and save user data. Search reads a PDF's existing text; it does not perform OCR. Highlight overlays live in memory until your application stores them, and they do not modify the PDF file.

These docs track the repository's `main` branch. If an API is missing from your installed package, compare its version with the [releases](https://github.com/anaralabs/lector/releases). The current source declares React 19+ and `pdfjs-dist` `^5.5.207` as peer dependencies.

Contributing to Lector itself? See the [contributor guide](https://github.com/anaralabs/lector/blob/main/CONTRIBUTING.md).
