Skip to content

Getting Started

To try React PDF library for free, simply follow the instruction in the docs. For commercial use, please purchase a license or reach out to us at david@react-pdf.dev.

Prerequisites

To run a PDF Viewer component in a React.js application, here is the basic system requirement:

  • React version: >= 18.0

If you are working with a React framework such as Next and Gatsby, React PDF can run smoothly as long as you are using React 18 and above.

React PDF also works well with other React.js UI libraries such as MUI, Ant Design and Chakra UI.

Although React PDF can run on most JavaScript module bundlers, it is more vigorously tested on Vite and Webpack.

Remark:
- If using TypeScript, it requires >= TypeScript 4.6.

Browser support

React PDF component is supported in modern browsers as follow:

ChromeFirefoxEdgeSafariSafari iOSChrome Android
115+115+115+16.5+16.5+126+

Installation

Install React PDF

There are a few ways you can install React PDF, namely bun, npm, pnpm or yarn.

To install using bun, run:

Terminal window
bun add @pdf-viewer/react
Caching of previous Worker version with bun

To clear cache, try running bun pm cache rm to remove cache in the global cache directory. If the error remains, try executing the following steps:

Terminal window
rm bun.lockb
rm -R node_modules

Please ensure that you follow this step if you want to override pdfjs-dist version. After that, you may execute this command to install all dependencies again.

Terminal window
bun i

Installation Issues

Apple M series

Since the default version of pdfjs-dist in React PDF requires the canvas package, you may need to manually add the canvas package for Apple M1 and later chipsets.

You may use Brew, a popular package manager to install the canvas dependencies:

Terminal window
$ brew install pkg-config cairo pango