Apryse Acquires Pdftools: Read the Announcement

Home

All Blogs

How to Build a React File Viewer for PDFs, Images & Office Docs

Published July 15, 2026

Updated July 16, 2026

Read time

7 min

email
linkedIn
twitter
link

How to Build a React File Viewer for PDFs, Images & Office Docs

Sanity Image

Isaac Maw

Technical Content Creator

Summary: Read this article to learn how to build a React file viewer for PDFs, images, and Office documents using Apryse WebViewer. This guide compares open-source React PDF viewer and DOCX viewer libraries, then walks through building a client-side React document viewer with no server dependencies. Discover why Apryse is the best React viewer for Office, plus how to extend it with editing and signatures.

Sanity Image

When standing up projects quickly, developers and coding LLMs often default to open-source libraries to build document processing functionality, such as PDF viewing, Office document viewing, PDF manipulation or conversion. This approach works great at first but isn’t always sustainable. It’s a great way to “build the plane as you’re flying it” as they say in startups, but as software applications scale, gain customers, and expand capabilities, those open-source libraries can quickly become the sore spot in your stack, becoming the source of endless maintenance and custom workarounds, additional libraries and more dependencies, and integration issues.

PDF Viewing alone is easier to implement using open-source JS libraries than broader document viewing that includes Office documents. For example, PDF.js and React-PDF are widely used and relatively robust. However, rendering Office documents in the browser has thinner support in the open-source community.

In fact, one of the most popular React libraries for rendering multiple document types, Cyntler/react-doc-viewer, is no longer maintained as of this writing, and still has over 150,000 weekly downloads on NPM. While this library does support rendering of several file types, including images, HTML, DOCX, XLSX, PPTX, and mp4, it does so using an array of renderers for each file type. These include third-party renderers. For example, according to the readme, react-doc-viewer uses the official MS Office online document viewing service. This means it works on an iframe basis and only supports public file URLs. In short, while it could be a great place to start for broad file rendering in a React app, you never really know where your data is going, as some of the renderers process your file server-side.

In this article, we’ll explore other potential challenges with popular open-source viewers, and show how to build Apryse WebViewer in React, our SDK that natively opens PDF, images, and Office documents securely on the client side with no external dependencies.

TL;DR:

Copied to clipboard

Check out the Apryse WebViewer integration guide to get started. The steps are simple:

  1. Get your trial key
  2. create a Vite project
  3. install WebViewer
  4. copy assets into your project
  5. use a single API call to load any document. WebViewer can be extended via paid add-ons for editing, redaction, digital signatures, and more.

React File Viewer Libraries Compared

Copied to clipboard

While open-source libraries can work for a simple PDF viewer in React, they fall short when an application needs to reliably render complex Office documents or when the underlying code hasn't been updated in a long time. For applications that depend on accurate DOCX, XLSX, and PPTX rendering, a maintained, purpose-built SDK like Apryse WebViewer closes that gap.

react-file-viewer

@cyntler/react-doc-viewer

Apryse WebViewer

Formats Supported

PDF, images, limited Office support. As shown in the documentation, File type support is powered by third-party libraries, such as PDF.js for PDF and Mammoth for DOCX. (Mammoth doesn’t render DOCX, it converts it to HTML for display, which can lead to rendering fidelity issues.)

PDF, images, CSV, basic Office support (fidelity varies by format) using an array of third-party libraries, including server-side processing.

PDF, PDF/A, DOCX, XLSX, PPTX, images (TIFF, PNG, JPG), and more

Maintenance

Limited maintenance, last commit was in 2024. Another library, react-file-viewer-V2, is inspired by this library and is still currently maintained, so developers may want to check that out.

The last commit date was in September 2025, and the NPM page states that it is no longer maintained as of 10 months ago (at the time of this writing)

Actively maintained commercial SDK with regular releases

License

Open source (MIT)

Open source (MIT)

Commercial, with free trial

Rendering Fidelity

Basic; not built for complex Office layouts

Inconsistent on complex DOCX/XLSX/PPTX; some paths rely on external hosted viewers rather than true client-side rendering

High-fidelity, WebAssembly-based rendering entirely in-browser

How to Get Started with WebViewer in React

Copied to clipboard

Apryse WebViewer fits into any modern React setup and is fully compatible with popular ecosystem tools like Next.js, Vite, and Create React App.

Step 1: Install the Core Package

Add the official WebViewer package to your project dependencies:

npm i @pdftron/webviewer 

WebViewer runs its highly optimized WASM rendering engine inside a separate browser worker thread. To support this, copy the static asset folders from node_modules/@pdftron/webviewer/public into your local project's static /public folder.

Step 3: Instantiate the React Component

Create a src/App.jsx file with the following code:

Now create a src/main.jsx file with the following code:

Adding More Capabilities

Copied to clipboard

WebViewer ships with a full editing and processing engine underneath it, so once your basic integration is working, you can layer in advanced capabilities without adding a separate library or rearchitecting your document workflow. Because licensing is modular with these add-ons, you’re not paying for capabilities you don't use.

In our WebViewer case studies, many of the customers I’ve spoken to have highlighted this feature extensibility and modular licensing as a benefit of choosing Apryse.

Explore some of the most commonly used features next:

  • PDF Editing: Add client-side PDF editing for responsive in-app interaction
  • Forms: Create, fill, and validate interactive form fields, including support for FDF and XFDF data.
  • Digital Signatures: Add digital signature workflows for AES and QES compliant signatures.
  • Redaction: Permanently remove sensitive text, images, or metadata to meet compliance requirements.
  • Page Manipulation: Merge, split, rotate, reorder, and extract pages programmatically.

Conclusion

Copied to clipboard

When you follow the integration steps above using your free trial key, you’re building with a secure React file viewer that renders PDF, Office, and image files with no external dependencies. From there, you can extend it with editing, forms, signatures, redaction, and more, using the same SDK you already have integrated.

The core advantage of this approach is that everything runs client-side. There's no server-side conversion step, no file upload round-trip, and no backend rendering pipeline to build or maintain. Documents load and render directly in the browser, which keeps your architecture simpler and your users' data on their own device.

Get started with your free trial and contact sales with any questions. You can also demo WebViewer in our showcase.

FAQ

Copied to clipboard

Q: How can I build a React.js file viewer for PDF, image, and Office files?
A: Use Apryse WebViewer. It's a drop-in React component that renders PDF, DOCX, PPTX, XLSX, and common image formats without any server-side conversion.

Q: What SDK should I use for PDF manipulation in React applications?
A: Apryse WebViewer covers both viewing and manipulation in one SDK. Beyond rendering, it exposes APIs for annotation, page manipulation, form filling, redaction, and digital signatures, so you don't need a separate library for editing versus display.

Q: How do you edit DOCX files in a React application?
A: Apryse enables direct text editing in DOCX files through its content editing API, letting users modify text, formatting, and layout in the browser. Changes save back to a valid DOCX, so there's no round-trip through a conversion service.

Q: Do I need a server to use the Apryse React viewer?
A: No. WebViewer runs fully client-side using WebAssembly, so rendering, editing, and most manipulation happen in the browser. You only need a server if you want to persist files or handle authentication, not for the viewer itself to function.

Q: How does the viewer handle custom fonts for Office documents?
A: It uses font substitution by default, so documents render correctly even without the original fonts installed. If exact font fidelity matters, you can supply your own font files, which the viewer will use instead of the substitute.

Q: Can I use Apryse WebViewer with Next.js or other React frameworks?
A: Yes. Since WebViewer is a standard React component, it works with Next.js and other React-based frameworks.

Q: Is Apryse WebViewer free to use?
A: Apryse offers a free trial with full SDK access, so you can build and test a complete integration before purchasing. Production use requires a commercial license, which you can get through the free trial signup covered above.

Q: Does the viewer support XLSX and PPTX files, not just Word documents?

A: Yes. Apryse WebViewer renders XLSX spreadsheets and PPTX presentations alongside DOCX and PDF, so you can build one Office document viewer that handles all common file types instead of stitching together separate libraries for each format.

Ready to get started?

Sign up for a free trial to begin implementing the Apryse SDK in your application!