Skip to content
Getting Started

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

  • React version: >= 18.0
  • React version: >= 19.0

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

React PDF Kit works not only with a React framework such as Next.js (App Router and Pages Router), Remix and Gatsby but 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.

Starting from @react-pdf-kit/viewer@^2.0.0, we officially support PDF.js 5 and default to PDF.js 5.4.530.

As newer PDF.js versions rely on more modern browser APIs, minimum supported browser versions have changed. Please review the compatibility details below before choosing a PDF.js version.

React PDF Kit v2.0.0 defaults to PDF.js 5.4.530.

ChromeFirefoxEdgeSafariSafari iOSChrome Android
126+126+126+18.4+18.4+126+

If you need broader browser compatibility, you can continue using PDF.js 4.10.38, which supports:

ChromeFirefoxEdgeSafariSafari iOSChrome Android
119+115+115+17.4+17.4+126+

To change the version of PDF.js used, refer to Overriding Dependency guide.

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

To install using bun, run:

Terminal window
bun add @react-pdf-kit/viewer

Remark: From v2 onwards, a new NPM package is used. To install v1 of React PDF, please run with @pdf-viewer/react.

Caching of previous Worker version with bun
Section titled “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

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

The React PDF Viewer component requires PDF.js (pdfjs-dist) as a peer dependency with a default version of 5.4.530.

You may override the default pdfjs-dist within React PDF Kit. For more information, refer to Dependency Override.

pdfjs-dist v5 is ESM-only. Most modern bundlers handle this without any configuration:

  • Vite — works out of the box
  • Turbopack (Next.js 15+) — works out of the box
  • Webpack 5 — works with proper ESM support enabled

Exception: Next.js 14 (Webpack). Next.js 14 has a known ESM interop bug that causes pdfjs-dist v5 to fail at module load time:

TypeError: Object.defineProperty called on non-object

If you are using Next.js 14, override pdfjs-dist to v4, which supports both ESM and CommonJS. See Dependency Override for more information.