Nuxt 3 Loading Component?
Hey guys,
I've just noticed that Nuxt 3 doesn't have the same loading component as V2. Is there a way I can use my old loading component with Nuxt 3? What's the best workaround for this?
22 Replies
NuxtLoadingIndicator is the equivalent for Nuxt 2 Loading component
https://nuxt.com/docs/api/components/nuxt-loading-indicator
That’s between page navigations, I want something for when the site initially loads.
You mean you have an spa with ssr: false?
I don’t but is that something I would need to do to get this working?
Can I not just use page:loading:start?
I'm asking because I'm not sure what's your use case
If you're using SSR (the default), then the page gets rendered at the server and served directly to the browser. Hence you won't need that initial loader on first load
Maybe something like this is what you need?
Yeah i need to add one on the inital load.
So i'm guessing if I do
ssr: false
and then just use spaLoadingTemplate:
Yeah Excactly
Can I use a vue file with spaLoadingTemplate or does it have to be HTML?
Also is it possible to actual customise the loading screen or is it just the spinner with spaLoadingTemplate?
IIRC it have to HTML.
I think I don't understand correctly your second question. You can do whatever you like in spaLoadingTemplate.html and that will show up on the client while it loads your app
Essentially I’m trying to work out how to do this in Nuxt 3:
https://debbie.codes/blog/nuxt-loading/
Where I can have a loading screen as a model with a progress bar/animation
Debbie Codes
Customizing the Nuxt Loading Component
We can customize the Loading for our Client Side applications as well as the loading Progress bar for our server rendered applications and we can even customize this to create our own.
Did you try the code I posted above? I think that is what you're asking for
This is pretty much what i'm after but the loading hook just didn't work at all
This is what I ended up doing instead. I have no idea why the
page:start
hook just didn't work at all.
That's weird maybe we're misunderstanding something 🤔 Anyway good thing you got it to work
I don't think you can hook page start inside the page
You can in composables so why not in pages?
If page started then how can the page itself know it has been started?
That's seems right but composables can only called in and pages components which is used in pages then how it's working for composables and not in pages
Logically it shouldn't in composables, can I see the code please?
Nuxt
Lifecycle Hooks · Nuxt Advanced
Nuxt provides a powerful hooking system to expand almost every aspect using hooks.
The example has a plugins file but it says it cal also be used in composables. The example has
page:start
hookSure you can use it in composables but not call
page:start
inside the page, but plugin instead.I'm agreeing with you it makes sense but after I've saw the docs I thought that there's some compiler thing that makes it work