Fill store/fetch data on route prefetch

Timkor
6
Timkor
commented 9 months ago

What problem does this feature solve?

Routes are now able to be prefetched similair to quicklink. The problem is that there still needs to be data fetched for some routes which implement asyncData and/or fetch. This can be solved by enabling the page to prefetch data or fill the store before the route is being requested.

Prefetching can be done before the actual route transition. That means, that it's possible that the data is fetched while the route transition will never happen. Some Nuxt.js project might have implemented fetch and asyncData in a way that it requires the route transition to happen.

What does the proposed changes look like?

There could either be a new method being introduced called prefetch on page components or there could be a flag which enables prefetching on fetch and/or asyncData. This way, this feature is backwardscompatible.

idea
0
Atinux
27.4k
Atinux
commented 9 months ago

I had the similar idea @Timkor when thinking of the prefetching feature ๐Ÿ˜„

This feature is worth exploring, but only after the new asyncData that could be called everywhere (and not only in pages/).

0
Informations
Feature Request โ€ข Open
#c8571 - Created 9 months ago