Isaac Maw
Technical Content Creator
Published June 30, 2026
Updated June 30, 2026
6 min
How to Use a React PDF Viewer: Apryse WebViewer SDK
Isaac Maw
Technical Content Creator

Summary: How do you use React for PDF Viewing?
TL;DR: To build a PDF Viewer in React, install Apryse WebViewer SDK, get your trial key, and load your first PDF with initialDoc. Apryse WebViewer provides a modular, customizable UI for viewing, annotating, editing, and working with PDFs and other document formats in React. Our documentation shows how to render and interact with PDFs in a React app using Vite.

How to Use a React PDF Viewer
React is a great library that enables developers to build responsive, powerful web apps using JavaScript. When these applications need secure, reliable PDF capabilities, developers often rely on open-source libraries like react-pdf, or rely on the browser’s built-in viewer, such as by using an iframe.
However, we’ve found that while these inexpensive, lightweight solutions are great for standing up an application, they quickly fall short as projects scale, with more users handling larger documents, and wanting to do more with those documents. When this happens, developers turn to Apryse WebViewer because it provides a single toolkit for a wide range of document capabilities, and it’s stable, polished and supported. Choosing WebViewer solves the PDF problems so developers can focus on other requirements.
In addition to PDF viewing, WebViewer provides:
- WCAG 2.2 Level AA Accessible UI
- Annotations
- Redaction
- Conversion
- Digital Signatures
- 100+ file types support
- CAD viewing and measurement
- PDF, DOCX and Spreadsheet editing
- Forms
- Document manipulation
- See more capabilities
What to Look for in a React PDF Viewer
A commercial SDK (like Apryse) beats free options and in-house development when it meets these key requirements:
- It’s easier and faster to integrate and maintain
- It’s more stable and secure, with features available for future extensibility
- It supports regulatory compliance with things like accessibility features and security certifications
- It offers licensing that fits your needs
Prefer to build a fully custom UI on top of Apryse's rendering engine? See our guide to building a custom React PDF viewer.
Why Use Apryse WebViewer SDK in React?
Building a PDF viewer from scratch involves much more than simply rendering pages. Production applications often need fast document loading, smooth navigation, annotation tools, form filling, search, editing capabilities, and support for multiple document types. Users need an accessible, intuitive experience.
Apryse WebViewer SDK packages these capabilities into a single JavaScript SDK that integrates cleanly with React, allowing developers to focus on building application workflows instead of implementing document functionality.
In a recent case study, we explored how Blue Voice, an AI-powered policy reference app for police officers, is built in React. In early stages, the company used open-source PDF viewer libraries to provide document viewing, annotation and form filling capabilities. However, the engineering team flagged that this code was starting to cause more problems than it solved, with users wanting a better experience, product wanting more features, and the engineering team wanting a more stable, low-maintenance build.
By integrating Apryse WebViewer, Blue Voice eliminated the work of building PDF functionality, allowing developers to focus on what differentiated the product, such as its AI features. Check out the case study for the full story.
“Apryse allowed us to stop spending engineering time rebuilding PDF functionality and focus on delivering value to law enforcement officers. The platform is stable, easy to integrate, and backed by a highly responsive team.”
Amit Patankar, CTO & Co-Founder, Blue Voice
Extensible and Flexible PDF Functionality
That Blue Voice experience of consolidating vendors to reduce dependencies and streamline the stack is a common one. While open-source libraries are great for basic functionality, Apryse offers add-on modules and a Server SDK that sets up your project for modular expansion, allowing your document capabilities to grow without running into dependency issues.
Beyond simply displaying PDFs, WebViewer provides a complete document experience from a single SDK. Developers can:
- View PDFs with responsive navigation and zoom controls
- Search document text
- Add highlights, comments, free text, stamps, and other annotations
- Fill and edit PDF forms
- Edit PDF content
- Compare document versions
- Redact sensitive information
- Digitally sign documents
- Manipulate pages by rotating, inserting, deleting, extracting, or rearranging them
- Save or export annotations and document changes
These capabilities can be enabled without assembling multiple libraries or building custom document tools. While some features are licensed seperately as add-ons, you can try everything free with your trial key.
Get Started with WebViewer in React
This guide assumes basic familiarity with React development. Before you start:
- Install Node.js and npm. See the Vite documentation for version details.
- Install Visual Studio Code or another code editor to develop and debug your code.
- Get your Apryse trial key.
1. Create a React Project
To start, we'll create a new React with Vite application using npm. In your terminal, go to the directory where you want to create the project. Then, create a new webviewer-react project using a minimal setup:
npx -y create-vite@latest webviewer-react --template reactIf prompted to install with npm and start now, select No. Next, navigate to your new React project directory and install dependencies:
cd webviewer-react
npm install2. Install WebViewer via npm
Next, install the Apryse WebViewer SDK using npm. This command adds the WebViewer package to your project, allowing you to integrate the PDF viewer and editor into your React application.
After navigating to your webviewer-react project directory, run the following command to install WebViewer:
npm i @pdftron/webviewer3. Copy WebViewer assets
WebViewer needs access to its static assets at runtime, including WebAssembly modules, HTML, and CSS files. In a React project, you must copy these assets into the public directory so they can be served correctly. For more, see Copying WebViewer static assets.
1. From your project root, create the public/lib/webviewer directory if it doesn't already exist:
npx --yes shx mkdir -p public/lib/webviewer2. Copy all WebViewer static assets from node_modules/@pdftron/webviewer/public into the new public/lib/webviewer directory:
npx --yes cpy-cli "node_modules/@pdftron/webviewer/public/**/*" public/lib/webviewerYour project should now include a similar structure:
webviewer-react/
├─ node_modules/
├─ public/
│ ├─ lib/
│ │ └─ webviewer/
│ │ ├─ core/
│ │ └─ ui/
│ ├─ favicon.svg
│ └─ ...
├─ src/
└── ...4. Create the PDF viewer
Next, instantiate the Apryse WebViewer SDK and mount it in your React project. This involves creating a container for the viewer and initializing WebViewer so it loads correctly at runtime.
- In Visual Studio Code, replace the contents of the
src/App.jsxfile with the following and save:
2. Replace the contents of the src/main.jsx file with the following and save:
5. Verify your output
You can now load and display a PDF document in the WebViewer UI. Run your React application to launch WebViewer and see the PDF in your browser.
- From your project directory, run the following command to start the application:
npm run devA successful output looks similar to:
2. Open the localhost URL from your terminal to view the WebViewer UI and PDF document.
Now, you're ready to check out the usage, WebViewer guides, samples, and API reference.
Conclusion
Apryse WebViewer SDK lets developers add a production-ready React PDF viewer with viewing, annotation, editing, and customization capabilities.
Get your trial key to start building a React PDF viewer with Apryse WebViewer SDK, or contact sales with questions.
FAQ
Q: How do I add a PDF viewer to React?
A: Install Apryse WebViewer SDK, create a container with useRef, initialize WebViewer in useEffect, and pass the PDF path through initialDoc.
Q: Can I annotate PDFs in React?
A: Yes. Apryse WebViewer includes annotation tools such as highlights, comments, shapes, free text, and markup workflows.
Q: Can I edit PDFs in React?
A: Yes. Apryse WebViewer supports PDF viewing, annotation, and editing workflows in the browser.
Q: Does Apryse WebViewer only support PDFs?
A: No. WebViewer supports PDFs and other formats including Office documents, images, videos, audio, and CAD files.
Q: Is Apryse WebViewer compatible with Vite?
A: Yes. Apryse provides a React and Vite getting-started guide for building a PDF viewer and editor.


