WebViewer is compatible with any JavaScript framework because it only needs a DOM element to place the document-viewing component. The following pre-built samples are available for quick integration, but it's easy to setup WebViewer with any framework.
Integrating WebViewer into a JavaScript framework (any framework) is broken down to three steps:
WebViewer can be integrated into your application in several ways, depending on your project setup. The main difference between these approaches is how WebViewer is loaded and how your project is structured.
Import using a script tag
This approach is best when you're working with plain HTML and JavaScript projects and want a quick setup with no build tools. For example, this could mean you're following a manual installation path that involves downloading the SDK. The integration doesn't require Node Package Manager (npm) or any build tools, and it's the fastest way to get started with the WebViewer library.
The import looks similar to this in your HTML:
This method is not ideal for large applications and lacks built-in module or dependency management.
Import using npm (recommended)
This approach is best when you're building a modern web application and want to manage dependencies using a package manager. For example, this could mean you're using a framework such as React, Angular, or Vue, or a build tool like Webpack, Vite, or Parcel. By installing WebViewer via npm, you download WebViewer from the npm registry. Both the JavaScript API and runtime assets are managed through the npm package. You can then import WebViewer directly into your JavaScript files using ES module syntax (import).
The integration looks similar to this in your JavaScript:
This method requires a build tool and a module-based setup, but provides better scalability, maintainability, and dependency management for larger applications.
Import using a hybrid approach
This approach is best when you're using a bundler but still need to host the WebViewer runtime files (lib folder) manually. For example, your application may use a build tool like Webpack, Vite, or Parcel, while the WebViewer SDK is downloaded and served from your own server. In this setup, WebViewer is installed from locally downloaded SDK files instead of the npm registry:
You can then use ES module syntax (import) in your application code, while WebViewer’s runtime files (UI assets, workers, etc.) are loaded separately from the manually hosted lib folder:
main.js
Because import is used, your HTML must load the JavaScript file with <script type="module"> for the browser to execute it correctly:
This approach can be useful in restricted or enterprise environments where direct npm installation is not preferred. While it offers flexibility, it's more complex than the script tag or full npm methods. It's typically recommended only for advanced or specialized use cases.
The WebViewer constructor takes two arguments: options and a DOM element. Regardless of the framework, you must pass a DOM element which will contain WebViewer's iframe.
Given the instantiation code:
you can reference a DOM element based on your framework:
Before calling APIs, you should wait for appropriate events to be fired from WebViewer.
and call APIs from viewer instance:
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales