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:
Chrome | Firefox | Edge | Safari | Safari iOS | Chrome 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:
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:
rm bun.lockbrm -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.
bun i
To install using npm
, run:
npm install @pdf-viewer/react
To install using pnpm
, run:
pnpm add @pdf-viewer/react
To install using yarn
, run:
yarn add @pdf-viewer/react
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:
$ brew install pkg-config cairo pango