JeremyLin
Nuxt Nitro lifecycle
Does anyone know what happens on the Nuxt Nitro server when a request is made, before the 00.middleware.global executes? Specifically, I am curious about the sequence of operations such as plugin initialization, router setup, and SSR template rendering. Could someone clarify the steps involved?
1 replies
How can I correctly display a loading screen without blocking the route in Nuxt3?
Hi!
I've encountered an unresolved issue while developing with Nuxt 3. In my project, each page has content that must be rendered only after the top-level setup requests are completed. However, I don't want to use useFetch, as it causes requests pending and blocks the route.
My expectation is for the route to immediately navigate and display a loading page until the request is complete, and then render the complete page. Yes, I know lazy loading can prevent route blocking, but it brings up the first issue.
I want to ensure SSR functionality on each page, but server-side doesn't trigger watch(which I use lazy fetch to make sure request done.), forcing me to use watchImmediate to ensure the expected HTML is correctly generated during SSR and sent to the client-side. However, this approach leads to another issue.
On the client side, when a page is re-entered for the second time (for example, requesting an offset form), because the last request depends on the payload, during the page's script phase, watchImmediate observes the data from the payload (i.e., the data from the first successful request) and immediately assumes the data has been requested.
This results in the initial appearance of the first entry page's value (from the payload) until the second request succeeds and refreshes the data. This prevents me from ensuring the normal display of loading on the client side.
Is it a misuse of my approach? Or is it necessary to sacrifice SSR if using lazy fetch?
I hope my description of the issue is clear enough. Please let me know if further clarification is needed.
Thanks!
1 replies