# react-pdf-hook

> The easiest way to usePdf()

Latest version **2.0.0** (published 2026-06-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-pdf-hook
pnpm add react-pdf-hook
yarn add react-pdf-hook
bun add react-pdf-hook
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2026-06-18 |
| First published | 2022-03-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 43 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| Maintainers | rubber-duck-software |

## Links

- npm: https://www.npmjs.com/package/react-pdf-hook
- Repository: https://github.com/rubber-duck-software/react-pdf-hook
- Homepage: https://github.com/rubber-duck-software/react-pdf-hook#readme
- Issues: https://github.com/rubber-duck-software/react-pdf-hook/issues
- npm.io page: https://npm.io/package/react-pdf-hook

## Recent versions

- 2.0.0 (latest) — 2026-06-18
- 1.0.4 — 2026-04-15
- 1.0.3 — 2023-05-01
- 1.0.2 — 2022-08-30
- 1.0.1 — 2022-03-26
- 1.0.0 — 2022-03-26

## README

<p align="center">
  <h1 align="center">react-pdf-hook</h1>
  <p align="center">The easiest way to usePdf()</p>
</p>

react-pdf-hook is designed to keep out of your way as you try to render pdf's in React. Inspired by the excellent
[react-pdf](https://github.com/wojtekmaj/react-pdf), react-pdf-hook provides a set of hooks (including an easy to use `usePdf` hook) which allows you to render a pdf in React.

Nearly all javascript pdf renderings rely on [PDF.js](https://mozilla.github.io/pdf.js/). react-pdf-hook is no exception! In fact, the first argument to `usePdf()` is PDF.js, which we assume is setup and ready to go. react-hook-pdf provides useful react abstractions on top of PDF.js.

### Example Usage

```js
import * as pdfjs from 'pdfjs-dist'
import { usePdf } from 'react-hook-pdf'
pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js`

function Pdf() {
  const { pdf, canvasRef } = usePdf(pdfjs, 'http://www.africau.edu/images/default/sample.pdf', 1, { width: 400 })

  return <canvas style={{ display: !pdf ? 'none' : undefined }} ref={canvasRef} />
}
```

---
_Source: https://npm.io/package/react-pdf-hook · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
