N
Nuxt7mo ago
Joni

Layout optional for page

Hello there, I have a page file download and want the layout to be optional / conditional by pinia store:
definePageMeta
layout: userStore.isLoggedIn ? "default" : "guest"
definePageMeta
layout: userStore.isLoggedIn ? "default" : "guest"
Due to SSR nuxt throws error "userStore is not defined"... Workaround is
if (userStore)
setPageLayout(userStore.isLoggedIn ? "default" : "guest");
if (userStore)
setPageLayout(userStore.isLoggedIn ? "default" : "guest");
Due to SSR I get a hydration error, what should be the correct thing to do here?
1 Reply
Joey
Joey7mo ago
This thread might be of use to you: https://github.com/nuxt/nuxt/issues/14658
GitHub
Change default layout programmatically · Issue #14658 · nuxt/nuxt
Describe the feature In Nuxt 2 there is a very nice method called $nuxt.setLayout('layout2'). Sadly in Nuxt 3, this functionality is nowhere to be found. The following method works but you ...
Want results from more Discord servers?
Add your server