Recently I created Website using Nuxtjs, Everything is going fine after that i added dark mode in website and then the problem starting, I saved dark mode data in local storage and when i call it from default page it works but after some sec first show normal page and then it changed to dark mode.
Hello Lili,
Recently I created Website using Nuxtjs, Everything is going fine after that i added dark mode in website and then the problem starting, I saved dark mode data in local storage and when i call it from default page it works but after some sec first show normal page and then it changed to dark mode.
Here is my code:
beforeMount() {
if (this.$ssrContext) return
this.$vuetify.theme.dark = localStorage.getItem('darkmode') === 'true'
},
After some time i know that beforeMount() is only working in client side that's why this happens.
I want to know what should i use to apply dark mode before render, In simple work i want to know alternative of beforeMount() in SSR
App Mode - Universal (Server Side Rendering)
Have you tried using cookie instead ?
You might find this helpful
github.com/microcipcip/cookie-univ...