Integrate WebViewer into Nuxt 2

This sample integrates WebViewer into a Nuxt 2 project. The project was created using the npm init nuxt-app command and utilizes the BootstrapVue UI Framework along with the NuxtJS module, which offers a promise-based HTTP client.

WebViewer provides a slick out-of-the-box responsive UI that enables you to view, annotate and manipulate PDFs and other document types inside any web project.

Once you generate your license key, it will automatically be included in your sample code below.

License Key


Click the button below to view the full project in GitHub.

1<template>
2 <div id="webviewer" ref="viewer" />
3</template>
4
5<script>
6export default {
7 name: 'WebViewer',
8 props: {
9 url: String
10 },
11 mounted () {
12 const WebViewer = globalThis.WebViewer;
13
14 if (!WebViewer) {
15 console.error('WebViewer script not loaded');
16 return;
17 }
18
19 WebViewer.Iframe({
20 path: '/lib/webviewer',
21 initialDoc: this.url,
22 licenseKey: 'your_license_key'
23 }, this.$refs.viewer).then((instance) => {
24 // call apis here
25 });
26 }
27};
28</script>
29
30<style>
31#webviewer {
32 height: 100vh;
33}
34</style>
35

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales