Getting started

Minimum requirements

React PDF Viewer is powered by React hooks completely. So it requires React 16.8 or later.
If you are using TypeScript, then it requires TypeScript 3.8 or later.
The TypeScript definition files of @react-pdf-viewer packages use export type syntax which is only available from TypeScript 3.8.

Installing packages

1. Installing pdfjs library
React PDF Viewer uses the APIs provided by the popular pdfjs library. Execute the following command from the root folder to install pdfjs:
npm install pdfjs-dist@2.6.347
The pdfjs-dist will be added to the dependencies section in package.json:
"dependencies": {
"pdfjs-dist": "^2.6.347"

Using the latest version of pdfjs-dist

The latest version of pdfjs-dist (2.9.359) uses some modern JavaScript features. It requires additional configurations. If you use one of the following starters, please take a look at the sample project for more details.
Create React AppUse with Create React App
ElectronUse with Electron
GatsbyJSUse with GatsbyJS
NextJSUse with NextJS
ParcelBundle with Parcel
RescriptsUse with Rescripts
SnowpackBundle with Snowpack
WebpackBundle with Webpack
Webpack + TypeScriptBundle with Webpack, TypeScript
2. Installing the core package
npm install @react-pdf-viewer/core@2.9.1