christophFroe
Dynamic routes with [...slug].vue not keeping components alive
We have a dynamic project loading everything from an API. What happens if we change the URL
1) In the middleware we use defineNuxtRouteMiddleware to catch the new route
2) Then all components react on the route change and update themselves with the new data, everything would be perfect but then ...
3) When everything is finished, due to the route change the root component and all other components are new mounted and are re-rendered. It's working but I hope we can make it more efficient.
Perhaps I don't understand the behavior of Nuxt correctly, so please correct me if I am wrong
My ideas/questions:
a) Is there a way to keep the components alive it's a SPA and should be the fastest in my opinion, instead of new mounting
b) Or which hook should we use to update the data after everything was new mounted?
c) ....
Thanks a lot for all answers.
Christoph
5 replies