import Vue from 'vue'
import VueApexCharts from 'vue-apexcharts'
Vue.use(VueApexCharts)
plugins: [
{ src: '~/plugins/VueApexChart.client.js', mode: 'client' },
],
Or Try:
plugins: [
{ src: '~/plugins/VueApexChart.js', ssr: false },
],
Or Try:
plugins: [
{ src: '~/plugins/VueApexChart.client.js'},
],
None of the methods for disabling ssr for a plugin mentioned in the documentation is working.
When you try to use
The plugin should be able to render only on client-side.
It is being rendered on server side as I get the error:
Cannot read property 'document' of undefined
The exact stack trace:
node_modules/apexcharts/dist/apexcharts.common.js
I need to use the plugin vue-apexcharts and I cannot disable ssr on it.
Thanks for the report. Please create a minimal reproduction on codesandbox that we can easily check.
Please re-open with a repro (https://template.nuxtjs.org)
same problem here @Atinux
please see: https://codesandbox.io/s/codesandbox-nuxt-3gndu (it hangs the browser sometimes)
For anybody trying to avoid this error on SSR:
components: {
vueApexCharts: () =>
process.client ? import('vue-apexcharts') : Promise.resolve({ render: (h: any) => h('div') }),
},
thanks, this solution worked for me. I'm glad with the result.
For anybody trying to avoid this error on SSR:
components: { vueApexCharts: () => process.client ? import('vue-apexcharts') : Promise.resolve({ render: (h: any) => h('div') }), },
Thanks
Is this issue still active? Or has it gotten an 'official' resolution yet? I'm getting a document is not defined
error despite marking the plugin as client-side only:
plugins: [
{ src: '~/plugins/vue-password-strength-meter', mode: 'client', ssr: false }
]
The Nuxt error is:
Error in beforeCreate hook: "ReferenceError: document is not defined"
(note: redundancy with ssr: false was for testing)
What is the content of your plugin?
(from https://www.npmjs.com/package/vue-password-strength-meter)
import Vue from 'vue'
import VuePasswordStrengthMeter from 'vue-password-strength-meter'
if (process.client) {
Vue.use(VuePasswordStrengthMeter)
}
plugins: [
{ src: '~/plugins/vue-password-strength-meter.client.js', mode: 'client' }
]
(trying to use the hint from developerKumar above)
components: {
Password: () =>
process.client
? import('vue-password-strength-meter')
: Promise.resolve({ render: h => h('div') })
}
@jasonbrookins actually you can directly wrap the Password component with <client-only>
:
```vue
````
Online demo: https://codesandbox.io/s/silent-dew-vm0fs
@jasonbrookins actually you can directly wrap the Password component with
<client-only>
:<template> <div> <client-only> <password v-model="password"/> </client-only> </div> </template> <script> import Password from "vue-password-strength-meter"; export default { components: { Password }, data: () => ({ password: "" }) }; </script>
Online demo: https://codesandbox.io/s/silent-dew-vm0fs
Thanks, S茅bastien!
Most helpful comment
For anybody trying to avoid this error on SSR: