Search code examples
vue.jsvuejs2nuxt.jsserver-side-rendering

How to solve document not defined error when using nuxtJS + Vue2-Editor?


I am trying to setup nuxtjs app with vue2-editor.if I try navigating to editor page via client navigation its loading but if i visit or refresh(eg.com/editor) page directly .i am getting document not defined error.

I have identified it because vue2 editor does not support ssr but i have disable it in nuxt-config.js for only client side.but error not going away.please share what i am doing wrong?

//plugin.quill-editor.js

import Vue from 'vue'

if (process.client) {
    const VueEditor = require('vue2-editor') //tried normal import as wel
    Vue.use(VueEditor)
}

//nuxt.config.js
plugins: [
   { src: '@plugins/quill-editor.js', mode: 'client' },
]

Solution

  • let VueEditor
    
    if (process.client) {
        VueEditor = require('vue2-editor').VueEditor
    }
    

    not doing anything in nuxt config or any plugin. only import method changed. its working now but i am still wondering why it is not working when i disable ssr in nuxt -config.js file