Do I need to use "lazy" with `useFetch/useAsyncData` when deploying to vercel?
So before I used to have a fully static fronted (nuxt-generate) and a backend API. Now with nuxt3 this got blurred. When I deploy to vercel (without changing any config), nuxt still builds the frontend fully static and backend is lambdas right? Meaning it's all generated at build time, which means I always have to use
lazy
right?7 Replies
From my undertanding, before I was using nuxt/auth (v2) which used localStorage, so I had to always "wait for the client"
But now I use auth-utils, which uses cookies, which are available server side, so I don't need to ever use lazy, right?
@danielroe sorry to tag you, but I've been trying to understand this for month, and I think you know it super well! 🙂
Pretty much:
Right?
lazy only affects whether you delay route navigation/displaying the component until the data comes in - it's not related to how you deploy. lazy: true will still wait on the server to get the data before sending HTML. (You can set
server: false
if you don't want this.)Yeah, actually I think I meant server:false (not lazy)
so unless I have a specific reason (e.g. I need localStorage) I should never user server:false, right?
yes.
if you are generating all your pages in advance, you only want to use
server: false
if you want to avoid the data fetch being fetched at build time, or if the data fetch depends on some client-side attribute like a user tokenBut say I have a page /account which displays different data for each user (depending on a httpOnly cookie) - Will that be generated at built time and display the same data to all users?
(I'm not using any specific route rules, just deploy to vercel/cloudflare_pages) as it is
If you're not running
nuxi generate
or otherwise prerendering those pages, then that should be fine.Amazing. Thanks a lot!