Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

docs: mention use case for <KeepAlive> in definePageMeta #8491

Merged
merged 3 commits into from
Oct 26, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/content/2.guide/2.directory-structure/1.pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ Of course, you are welcome to define metadata for your own use throughout your a

#### `keepalive`

Nuxt will automatically wrap your page in [the Vue `<KeepAlive>` component](https://vuejs.org/guide/built-ins/keep-alive.html#keepalive) if you set `keepalive: true` in your `definePageMeta`. This might be useful to do, for example, in a parent route that has dynamic child routes, if you want to preserve page state across route changes. You can also set props to be passed to `<KeepAlive>` (see a full list [here](https://vuejs.org/api/built-in-components.html#keepalive)).
Nuxt will automatically wrap your page in [the Vue `<KeepAlive>` component](https://vuejs.org/guide/built-ins/keep-alive.html#keepalive) if you set `keepalive: true` in your `definePageMeta`. This might be useful to do, for example, in a parent route that has dynamic child routes, if you want to preserve page state across route changes.
danielroe marked this conversation as resolved.
Show resolved Hide resolved

When your goal is to preserve state for parent routes use this syntax: `<NuxtPage :keepalive="{ include: 'index' }" />`. You can also set props to be passed to `<KeepAlive>` (see a full list [here](https://vuejs.org/api/built-in-components.html#keepalive)).
danielroe marked this conversation as resolved.
Show resolved Hide resolved

You can set a default value for this property [in your `nuxt.config`](/api/configuration/nuxt-config#keepalive).

Expand Down