keepalive `include`/`exclude` props don't work with `<NuxtPage>`
See original GitHub issueEnvironment
- Operating System:
Windows_NT
- Node Version:
v16.16.0
- Nuxt Version:
3.0.0-rc.11
- Nitro Version:
0.5.4
- Package Manager:
npm@8.11.0
- Builder:
vite
- User Config:
-
- Runtime Modules:
-
- Build Modules:
-
Reproduction
https://stackblitz.com/edit/github-xnrjjn?file=pages%2Findex.vue,pages%2Fnotkeptalive.vue
Describe the bug
App has 2 pages, one page is set to be kept alive with
definePageMeta({ keepalive: true });
the other one is not.
Changing some value in the first page, is not kept if you navigate away from it and if you come back. Also, there is a weird display bug, as if a new mounted component of the page was added under the first one in the page before the first one being added. It make the page flicker.
If you put the same page meta in the second one (by removing the comment is the reproduction link), now it works, but the two pages are now kept alive and this is not what I want.
In base vue3, I could do something like that :
<router-view v-slot="{ Component }">
<keep-alive include="index">
<component :is="Component" />
</keep-alive>
</router-view>
Additional context
No response
Logs
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:11 (7 by maintainers)
Top Results From Across the Web
[rc.8] keep alive components get destroyed when navigating to ...
I'm not sure if this behavior was done on purpose. But I can say that Vue handles include/exclude differently and does not destroy...
Read more >How to exclude specific component from caching Using Nuxt ...
I have trouble with Nuxt.js keep-alive prop, I am trying to cache all components except one, and load dynamic data again.
Read more >Built-in Components - Nuxt
Both, the <Nuxt> component and the <NuxtChild/> component, accept keep-alive and keep-alive-props. To learn more about keep-alive and keep-alive-props see the ...
Read more >Migrate to Nuxt 3: Pages and Layouts
In Nuxt 3, these have been replaced with a single <NuxtPage> component. Page Keys and Keep-alive Props. If you were passing a custom...
Read more >Nuxt Exclude page from keep-alive - StackBlitz
<nuxt-link to="/about">About</nuxt-link>. </nav>. <p>See browser console</p>. <Nuxt keep-alive :keep-alive-props=". {exclude: ['pages/basket.vue']}" />.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, this is definitely on the roadmap and needs to be fixed.
@danielroe It does not work. I have inspected it with chrome vue dev tool and here is the problem. Under the KeepAlive there is a Anonymous element created around the Index element and because is it not exactly under the KeepAlive the include does not work. When the keepalive is setup globaly, it is the Anonymous object that are kept alive, not the one from the ./pages.
Two joint picture from the Chrome dev tool. With the include in the, ie
With the keepalive set globaly, you can see another Anonymous under the KeepAlive

<NuxtPage :keepalive="{ include : 'index' }">
This bug isn’t closed IMHO.