@nuxt/docs-nightly 4.2.1-29360927.606ef13e → 4.2.1-29360990.b3040970
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/1.getting-started/02.installation.md +2 -2
- package/1.getting-started/03.configuration.md +4 -4
- package/1.getting-started/04.views.md +2 -2
- package/1.getting-started/05.assets.md +1 -1
- package/1.getting-started/06.styling.md +11 -11
- package/1.getting-started/09.transitions.md +6 -6
- package/1.getting-started/10.data-fetching.md +2 -2
- package/1.getting-started/11.state-management.md +2 -2
- package/1.getting-started/12.error-handling.md +4 -4
- package/1.getting-started/13.server.md +4 -4
- package/1.getting-started/14.layers.md +1 -1
- package/1.getting-started/17.testing.md +3 -3
- package/1.getting-started/18.upgrade.md +3 -3
- package/2.guide/1.directory-structure/1.app/1.components.md +4 -4
- package/2.guide/1.directory-structure/1.app/1.composables.md +1 -1
- package/2.guide/1.directory-structure/1.app/1.layouts.md +2 -2
- package/2.guide/1.directory-structure/1.app/1.middleware.md +4 -4
- package/2.guide/1.directory-structure/1.app/1.pages.md +13 -13
- package/2.guide/1.directory-structure/1.app/1.plugins.md +1 -1
- package/2.guide/1.directory-structure/1.node_modules.md +1 -1
- package/2.guide/1.directory-structure/1.public.md +1 -1
- package/2.guide/1.directory-structure/1.server.md +2 -2
- package/2.guide/1.directory-structure/2.env.md +1 -1
- package/2.guide/2.concepts/1.auto-imports.md +2 -2
- package/2.guide/2.concepts/10.nuxt-lifecycle.md +3 -3
- package/2.guide/2.concepts/2.vuejs-development.md +3 -3
- package/2.guide/2.concepts/3.rendering.md +4 -4
- package/2.guide/2.concepts/7.esm.md +2 -2
- package/2.guide/2.concepts/9.code-style.md +1 -1
- package/2.guide/3.going-further/1.experimental-features.md +2 -2
- package/2.guide/3.going-further/1.features.md +1 -1
- package/2.guide/3.going-further/1.internals.md +2 -2
- package/2.guide/3.going-further/2.hooks.md +1 -1
- package/2.guide/3.going-further/3.modules.md +2 -2
- package/2.guide/3.going-further/6.nuxt-app.md +5 -5
- package/2.guide/3.going-further/7.layers.md +2 -2
- package/2.guide/3.going-further/9.debugging.md +1 -1
- package/2.guide/4.recipes/1.custom-routing.md +4 -4
- package/2.guide/4.recipes/3.custom-usefetch.md +1 -1
- package/2.guide/5.best-practices/hydration.md +1 -1
- package/3.api/1.components/10.nuxt-picture.md +1 -1
- package/3.api/1.components/11.teleports.md +1 -1
- package/3.api/1.components/12.nuxt-route-announcer.md +1 -1
- package/3.api/1.components/2.nuxt-page.md +1 -1
- package/3.api/1.components/4.nuxt-link.md +11 -11
- package/3.api/1.components/5.nuxt-loading-indicator.md +1 -1
- package/3.api/1.components/6.nuxt-error-boundary.md +1 -1
- package/3.api/2.composables/use-app-config.md +1 -1
- package/3.api/2.composables/use-cookie.md +6 -6
- package/3.api/2.composables/use-fetch.md +1 -1
- package/3.api/2.composables/use-nuxt-app.md +6 -6
- package/3.api/2.composables/use-route.md +1 -1
- package/3.api/2.composables/use-router.md +15 -15
- package/3.api/2.composables/use-state.md +1 -1
- package/3.api/3.utils/abort-navigation.md +2 -2
- package/3.api/3.utils/define-lazy-hydration-component.md +4 -4
- package/3.api/3.utils/define-nuxt-component.md +1 -1
- package/3.api/3.utils/define-nuxt-plugin.md +1 -1
- package/3.api/3.utils/define-nuxt-route-middleware.md +1 -1
- package/3.api/3.utils/define-page-meta.md +8 -8
- package/3.api/3.utils/navigate-to.md +4 -4
- package/3.api/3.utils/on-before-route-leave.md +1 -1
- package/3.api/3.utils/on-before-route-update.md +1 -1
- package/3.api/3.utils/update-app-config.md +2 -2
- package/3.api/5.kit/1.modules.md +2 -2
- package/3.api/5.kit/14.builder.md +6 -6
- package/3.api/6.advanced/1.hooks.md +5 -5
- package/3.api/6.nuxt-config.md +24 -24
- package/5.community/4.contribution.md +1 -1
- package/5.community/5.framework-contribution.md +8 -8
- package/5.community/6.roadmap.md +3 -3
- package/6.bridge/4.plugins-and-middleware.md +1 -1
- package/7.migration/2.configuration.md +2 -2
- package/7.migration/20.module-authors.md +1 -1
- package/7.migration/5.plugins-and-middleware.md +1 -1
- package/7.migration/6.pages-and-layouts.md +2 -2
- package/README.md +1 -1
- package/package.json +1 -1
|
@@ -30,12 +30,12 @@ Or follow the steps below to set up a new Nuxt project on your computer.
|
|
|
30
30
|
:summary[Additional notes for an optimal setup:]
|
|
31
31
|
- **Node.js**: Make sure to use an even numbered version (20, 22, etc.)
|
|
32
32
|
- **Nuxtr**: Install the community-developed [Nuxtr extension](https://marketplace.visualstudio.com/items?itemName=Nuxtr.nuxtr-vscode)
|
|
33
|
-
- **WSL**: If you are using Windows and experience slow HMR, you may want to try using [WSL (Windows Subsystem for Linux)](https://
|
|
33
|
+
- **WSL**: If you are using Windows and experience slow HMR, you may want to try using [WSL (Windows Subsystem for Linux)](https://learn.microsoft.com/en-us/windows/wsl/install) which may solve some performance issues.
|
|
34
34
|
- **Windows slow DNS resolution** - instead of using `localhost:3000` for local dev server on Windows, use `127.0.0.1` for much faster loading experience on browsers.
|
|
35
35
|
::
|
|
36
36
|
::
|
|
37
37
|
|
|
38
|
-
Open a terminal (if you're using [Visual Studio Code](https://code.visualstudio.com), you can open an [integrated terminal](https://code.visualstudio.com/docs/
|
|
38
|
+
Open a terminal (if you're using [Visual Studio Code](https://code.visualstudio.com), you can open an [integrated terminal](https://code.visualstudio.com/docs/terminal/basics)) and use the following command to create a new starter project:
|
|
39
39
|
|
|
40
40
|
::code-group{sync="pm"}
|
|
41
41
|
|
|
@@ -124,7 +124,7 @@ const appConfig = useAppConfig()
|
|
|
124
124
|
</script>
|
|
125
125
|
```
|
|
126
126
|
|
|
127
|
-
:read-more{to="/docs/4.x/guide/directory-structure/app-config"}
|
|
127
|
+
:read-more{to="/docs/4.x/guide/directory-structure/app/app-config"}
|
|
128
128
|
|
|
129
129
|
## `runtimeConfig` vs. `app.config`
|
|
130
130
|
|
|
@@ -160,9 +160,9 @@ Name | Config File | How To
|
|
|
160
160
|
---------------------------------------------|-------------------------|--------------------------
|
|
161
161
|
[TypeScript](https://www.typescriptlang.org) | `tsconfig.json` | [More Info](/docs/4.x/guide/directory-structure/tsconfig)
|
|
162
162
|
[ESLint](https://eslint.org) | `eslint.config.js` | [More Info](https://eslint.org/docs/latest/use/configure/configuration-files)
|
|
163
|
-
[Prettier](https://prettier.io) | `prettier.config.js` | [More Info](https://prettier.io/docs/
|
|
164
|
-
[Stylelint](https://stylelint.io) | `stylelint.config.js` | [More Info](https://stylelint.io/user-guide/configure)
|
|
165
|
-
[TailwindCSS](https://tailwindcss.com) | `tailwind.config.js` | [More Info](https://tailwindcss.nuxtjs.org/tailwindcss/configuration)
|
|
163
|
+
[Prettier](https://prettier.io) | `prettier.config.js` | [More Info](https://prettier.io/docs/configuration.html)
|
|
164
|
+
[Stylelint](https://stylelint.io) | `stylelint.config.js` | [More Info](https://stylelint.io/user-guide/configure/)
|
|
165
|
+
[TailwindCSS](https://tailwindcss.com) | `tailwind.config.js` | [More Info](https://tailwindcss.nuxtjs.org/tailwindcss/configuration/)
|
|
166
166
|
[Vitest](https://vitest.dev) | `vitest.config.ts` | [More Info](https://vitest.dev/config/)
|
|
167
167
|
|
|
168
168
|
## Vue Configuration
|
|
@@ -57,7 +57,7 @@ Most components are reusable pieces of the user interface, like buttons and menu
|
|
|
57
57
|
|
|
58
58
|
Pages represent views for each specific route pattern. Every file in the [`app/pages/`](/docs/4.x/guide/directory-structure/app/pages) directory represents a different route displaying its content.
|
|
59
59
|
|
|
60
|
-
To use pages, create an `app/pages/index.vue` file and add `<NuxtPage />` component to the [`app/app.vue`](/docs/4.x/guide/directory-structure/app) (or remove `app/app.vue` for default entry). You can now create more pages and their corresponding routes by adding new files in the [`app/pages/`](/docs/4.x/guide/directory-structure/app/pages) directory.
|
|
60
|
+
To use pages, create an `app/pages/index.vue` file and add `<NuxtPage />` component to the [`app/app.vue`](/docs/4.x/guide/directory-structure/app/app) (or remove `app/app.vue` for default entry). You can now create more pages and their corresponding routes by adding new files in the [`app/pages/`](/docs/4.x/guide/directory-structure/app/pages) directory.
|
|
61
61
|
|
|
62
62
|
::code-group
|
|
63
63
|
|
|
@@ -91,7 +91,7 @@ To use pages, create an `app/pages/index.vue` file and add `<NuxtPage />` compon
|
|
|
91
91
|
Layouts are wrappers around pages that contain a common User Interface for several pages, such as header and footer displays. Layouts are Vue files using `<slot />` components to display the **page** content. The `app/layouts/default.vue` file will be used by default. Custom layouts can be set as part of your page metadata.
|
|
92
92
|
|
|
93
93
|
::note
|
|
94
|
-
If you only have a single layout in your application, we recommend using [`app/app.vue`](/docs/4.x/guide/directory-structure/app) with [`<NuxtPage />`](/docs/4.x/api/components/nuxt-page) instead.
|
|
94
|
+
If you only have a single layout in your application, we recommend using [`app/app.vue`](/docs/4.x/guide/directory-structure/app/app) with [`<NuxtPage />`](/docs/4.x/api/components/nuxt-page) instead.
|
|
95
95
|
::
|
|
96
96
|
|
|
97
97
|
::code-group
|
|
@@ -30,7 +30,7 @@ For example, referencing an image file in the `public/img/` directory, available
|
|
|
30
30
|
|
|
31
31
|
## Assets Directory
|
|
32
32
|
|
|
33
|
-
Nuxt uses [Vite](https://vite.dev/guide/assets
|
|
33
|
+
Nuxt uses [Vite](https://vite.dev/guide/assets) (default) or [webpack](https://webpack.js.org/guides/asset-management/) to build and bundle your application. The main function of these build tools is to process JavaScript files, but they can be extended through [plugins](https://vite.dev/plugins/) (for Vite) or [loaders](https://webpack.js.org/loaders/) (for webpack) to process other kinds of assets, like stylesheets, fonts or SVGs. This step transforms the original file, mainly for performance or caching purposes (such as stylesheet minification or browser cache invalidation).
|
|
34
34
|
|
|
35
35
|
By convention, Nuxt uses the [`app/assets/`](/docs/4.x/guide/directory-structure/app/assets) directory to store these files but there is no auto-scan functionality for this directory, and you can use any other name for it.
|
|
36
36
|
|
|
@@ -163,7 +163,7 @@ export default defineNitroPlugin((nitro) => {
|
|
|
163
163
|
})
|
|
164
164
|
```
|
|
165
165
|
|
|
166
|
-
External stylesheets are render-blocking resources: they must be loaded and processed before the browser renders the page. Web pages that contain unnecessarily large styles take longer to render. You can read more about it on [web.dev](https://web.dev/defer-non-critical-css).
|
|
166
|
+
External stylesheets are render-blocking resources: they must be loaded and processed before the browser renders the page. Web pages that contain unnecessarily large styles take longer to render. You can read more about it on [web.dev](https://web.dev/articles/defer-non-critical-css).
|
|
167
167
|
|
|
168
168
|
## Using Preprocessors
|
|
169
169
|
|
|
@@ -206,7 +206,7 @@ export default defineNuxtConfig({
|
|
|
206
206
|
In both cases, the compiled stylesheets will be inlined in the HTML rendered by Nuxt.
|
|
207
207
|
::
|
|
208
208
|
|
|
209
|
-
If you need to inject code in pre-processed files, like a [Sass partial](https://sass-lang.com/documentation/at-rules/use
|
|
209
|
+
If you need to inject code in pre-processed files, like a [Sass partial](https://sass-lang.com/documentation/at-rules/use/#partials) with color variables, you can do so with the Vite [preprocessors options](https://vite.dev/config/shared-options#css-preprocessoroptions).
|
|
210
210
|
|
|
211
211
|
Create some partials in your `app/assets` directory:
|
|
212
212
|
|
|
@@ -258,11 +258,11 @@ export default defineNuxtConfig({
|
|
|
258
258
|
|
|
259
259
|
::
|
|
260
260
|
|
|
261
|
-
Nuxt uses Vite by default. If you wish to use webpack instead, refer to each preprocessor loader [documentation](https://webpack.js.org/loaders/sass-loader).
|
|
261
|
+
Nuxt uses Vite by default. If you wish to use webpack instead, refer to each preprocessor loader [documentation](https://webpack.js.org/loaders/sass-loader/).
|
|
262
262
|
|
|
263
263
|
### Preprocessor Workers (Experimental)
|
|
264
264
|
|
|
265
|
-
Vite has made available an [experimental option](https://vite.dev/config/shared-options
|
|
265
|
+
Vite has made available an [experimental option](https://vite.dev/config/shared-options#css-preprocessormaxworkers) which can speed up using preprocessors.
|
|
266
266
|
|
|
267
267
|
You can enable this in your `nuxt.config`:
|
|
268
268
|
|
|
@@ -284,7 +284,7 @@ This is an experimental option and you should refer to the Vite documentation an
|
|
|
284
284
|
|
|
285
285
|
One of the best things about Vue and SFC is how great it is at naturally dealing with styling. You can directly write CSS or preprocessor code in the style block of your components file, therefore you will have fantastic developer experience without having to use something like CSS-in-JS. However if you wish to use CSS-in-JS, you can find 3rd party libraries and modules that support it, such as [pinceau](https://github.com/Tahul/pinceau).
|
|
286
286
|
|
|
287
|
-
You can refer to the [Vue docs](https://vuejs.org/api/sfc-css-features
|
|
287
|
+
You can refer to the [Vue docs](https://vuejs.org/api/sfc-css-features) for a comprehensive reference about styling components in SFC.
|
|
288
288
|
|
|
289
289
|
### Class And Style Bindings
|
|
290
290
|
|
|
@@ -354,7 +354,7 @@ const styleObject = reactive({ color: 'red', fontSize: '13px' })
|
|
|
354
354
|
|
|
355
355
|
::
|
|
356
356
|
|
|
357
|
-
Refer to the [Vue docs](https://vuejs.org/guide/essentials/class-and-style
|
|
357
|
+
Refer to the [Vue docs](https://vuejs.org/guide/essentials/class-and-style) for more information.
|
|
358
358
|
|
|
359
359
|
### Dynamic Styles With `v-bind`
|
|
360
360
|
|
|
@@ -447,7 +447,7 @@ SFC style blocks support preprocessor syntax. Vite comes with built-in support f
|
|
|
447
447
|
|
|
448
448
|
::
|
|
449
449
|
|
|
450
|
-
You can refer to the [Vite CSS docs](https://vite.dev/guide/features
|
|
450
|
+
You can refer to the [Vite CSS docs](https://vite.dev/guide/features#css) and the [@vitejs/plugin-vue docs](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue).
|
|
451
451
|
For webpack users, refer to the [vue loader docs](https://vue-loader.vuejs.org).
|
|
452
452
|
|
|
453
453
|
## Using PostCSS
|
|
@@ -478,7 +478,7 @@ By default, Nuxt comes with the following plugins already pre-configured:
|
|
|
478
478
|
- [postcss-import](https://github.com/postcss/postcss-import): Improves the `@import` rule
|
|
479
479
|
- [postcss-url](https://github.com/postcss/postcss-url): Transforms `url()` statements
|
|
480
480
|
- [autoprefixer](https://github.com/postcss/autoprefixer): Automatically adds vendor prefixes
|
|
481
|
-
- [cssnano](https://cssnano.github.io/cssnano): Minification and purge
|
|
481
|
+
- [cssnano](https://cssnano.github.io/cssnano/): Minification and purge
|
|
482
482
|
|
|
483
483
|
## Leveraging Layouts For Multiple Styles
|
|
484
484
|
|
|
@@ -517,7 +517,7 @@ Here are a few modules to help you get started:
|
|
|
517
517
|
- [Nuxt UI](https://ui.nuxt.com): A UI Library for Modern Web Apps
|
|
518
518
|
- [Panda CSS](https://panda-css.com/docs/installation/nuxt): CSS-in-JS engine that generates atomic CSS at build time
|
|
519
519
|
|
|
520
|
-
Nuxt modules provide you with a good developer experience out of the box, but remember that if your favorite tool doesn't have a module, it doesn't mean that you can't use it with Nuxt! You can configure it yourself for your own project. Depending on the tool, you might need to use a [Nuxt plugin](/docs/4.x/guide/directory-structure/plugins) and/or [make your own module](/docs/4.x/guide/going-further/modules). Share them with the [community](/modules) if you do!
|
|
520
|
+
Nuxt modules provide you with a good developer experience out of the box, but remember that if your favorite tool doesn't have a module, it doesn't mean that you can't use it with Nuxt! You can configure it yourself for your own project. Depending on the tool, you might need to use a [Nuxt plugin](/docs/4.x/guide/directory-structure/app/plugins) and/or [make your own module](/docs/4.x/guide/going-further/modules). Share them with the [community](/modules) if you do!
|
|
521
521
|
|
|
522
522
|
### Easily Load Webfonts
|
|
523
523
|
|
|
@@ -535,7 +535,7 @@ Nuxt comes with the same `<Transition>` element that Vue has, and also has suppo
|
|
|
535
535
|
|
|
536
536
|
### Font Advanced Optimization
|
|
537
537
|
|
|
538
|
-
We would recommend using [Fontaine](https://github.com/nuxt-modules/fontaine) to reduce your [CLS](https://web.dev/cls). If you need something more advanced, consider creating a Nuxt module to extend the build process or the Nuxt runtime.
|
|
538
|
+
We would recommend using [Fontaine](https://github.com/nuxt-modules/fontaine) to reduce your [CLS](https://web.dev/articles/cls). If you need something more advanced, consider creating a Nuxt module to extend the build process or the Nuxt runtime.
|
|
539
539
|
|
|
540
540
|
::tip
|
|
541
541
|
Always remember to take advantage of the various tools and techniques available in the Web ecosystem at large to make styling your application easier and more efficient. Whether you're using native CSS, a preprocessor, postcss, a UI library or a module, Nuxt has got you covered. Happy styling!
|
|
@@ -551,7 +551,7 @@ You can do the following to speed-up the download of your global CSS files:
|
|
|
551
551
|
- Host your assets on the same domain (do not use a different subdomain)
|
|
552
552
|
|
|
553
553
|
Most of these things should be done for you automatically if you're using modern platforms like Cloudflare, Netlify or Vercel.
|
|
554
|
-
You can find an LCP optimization guide on [web.dev](https://web.dev/optimize-lcp).
|
|
554
|
+
You can find an LCP optimization guide on [web.dev](https://web.dev/articles/optimize-lcp).
|
|
555
555
|
|
|
556
556
|
If all of your CSS is inlined by Nuxt, you can (experimentally) completely stop external CSS files from being referenced in your rendered HTML.
|
|
557
557
|
You can achieve that with a hook, that you can place in a module, or in your Nuxt configuration file.
|
|
@@ -5,7 +5,7 @@ navigation.icon: i-lucide-toggle-right
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
::note
|
|
8
|
-
Nuxt leverages Vue's [`<Transition>`](https://vuejs.org/guide/built-ins/transition
|
|
8
|
+
Nuxt leverages Vue's [`<Transition>`](https://vuejs.org/guide/built-ins/transition#the-transition-component) component to apply transitions between pages and layouts.
|
|
9
9
|
::
|
|
10
10
|
|
|
11
11
|
## Page Transitions
|
|
@@ -24,7 +24,7 @@ export default defineNuxtConfig({
|
|
|
24
24
|
If you are changing layouts as well as page, the page transition you set here will not run. Instead, you should set a [layout transition](/docs/4.x/getting-started/transitions#layout-transitions).
|
|
25
25
|
::
|
|
26
26
|
|
|
27
|
-
To start adding transition between your pages, add the following CSS to your [`app.vue`](/docs/4.x/guide/directory-structure/app):
|
|
27
|
+
To start adding transition between your pages, add the following CSS to your [`app.vue`](/docs/4.x/guide/directory-structure/app/app):
|
|
28
28
|
|
|
29
29
|
::code-group
|
|
30
30
|
|
|
@@ -125,7 +125,7 @@ export default defineNuxtConfig({
|
|
|
125
125
|
})
|
|
126
126
|
```
|
|
127
127
|
|
|
128
|
-
To start adding transition between your pages and layouts, add the following CSS to your [`app.vue`](/docs/4.x/guide/directory-structure/app):
|
|
128
|
+
To start adding transition between your pages and layouts, add the following CSS to your [`app.vue`](/docs/4.x/guide/directory-structure/app/app):
|
|
129
129
|
|
|
130
130
|
::code-group
|
|
131
131
|
|
|
@@ -229,7 +229,7 @@ definePageMeta({
|
|
|
229
229
|
|
|
230
230
|
You can customize these default transition names globally using `nuxt.config`.
|
|
231
231
|
|
|
232
|
-
Both `pageTransition` and `layoutTransition` keys accept [`TransitionProps`](https://vuejs.org/api/built-in-components
|
|
232
|
+
Both `pageTransition` and `layoutTransition` keys accept [`TransitionProps`](https://vuejs.org/api/built-in-components#transition) as JSON serializable values where you can pass the `name`, `mode` and other valid transition-props of the custom CSS transition.
|
|
233
233
|
|
|
234
234
|
```ts twoslash [nuxt.config.ts]
|
|
235
235
|
export default defineNuxtConfig({
|
|
@@ -310,7 +310,7 @@ definePageMeta({
|
|
|
310
310
|
```
|
|
311
311
|
|
|
312
312
|
::tip
|
|
313
|
-
Learn more about additional [JavaScript hooks](https://vuejs.org/guide/built-ins/transition
|
|
313
|
+
Learn more about additional [JavaScript hooks](https://vuejs.org/guide/built-ins/transition#javascript-hooks) available in the `Transition` component.
|
|
314
314
|
::
|
|
315
315
|
|
|
316
316
|
## Dynamic Transitions
|
|
@@ -416,7 +416,7 @@ Remember, this page transition cannot be overridden with `definePageMeta` on ind
|
|
|
416
416
|
|
|
417
417
|
## View Transitions API (experimental)
|
|
418
418
|
|
|
419
|
-
Nuxt ships with an experimental implementation of the [**View Transitions API**](https://developer.chrome.com/docs/web-platform/view-transitions) (see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/
|
|
419
|
+
Nuxt ships with an experimental implementation of the [**View Transitions API**](https://developer.chrome.com/docs/web-platform/view-transitions) (see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/View_Transition_API)). This is an exciting new way to implement native browser transitions which (among other things) have the ability to transition between unrelated elements on different pages.
|
|
420
420
|
|
|
421
421
|
You can check a demo [on StackBlitz](https://stackblitz.com/edit/nuxt-view-transitions).
|
|
422
422
|
|
|
@@ -516,7 +516,7 @@ const { data, status } = useLazyFetch('/api/user', {
|
|
|
516
516
|
</script>
|
|
517
517
|
```
|
|
518
518
|
|
|
519
|
-
In the case of more complex URL construction, you may use a callback as a [computed getter](https://vuejs.org/guide/essentials/computed
|
|
519
|
+
In the case of more complex URL construction, you may use a callback as a [computed getter](https://vuejs.org/guide/essentials/computed) that returns the URL string.
|
|
520
520
|
|
|
521
521
|
Every time a dependency changes, the data will be fetched using the newly constructed URL. Combine this with [not-immediate](/docs/4.x/getting-started/data-fetching#not-immediate), and you can wait until the reactive element changes before fetching.
|
|
522
522
|
|
|
@@ -771,7 +771,7 @@ const { data } = await useFetch('/api/superjson', {
|
|
|
771
771
|
### Consuming SSE (Server-Sent Events) via POST request
|
|
772
772
|
|
|
773
773
|
::tip
|
|
774
|
-
If you're consuming SSE via GET request, you can use [`EventSource`](https://developer.mozilla.org/en-US/docs/Web/API/EventSource) or VueUse composable [`useEventSource`](https://vueuse.org/core/
|
|
774
|
+
If you're consuming SSE via GET request, you can use [`EventSource`](https://developer.mozilla.org/en-US/docs/Web/API/EventSource) or VueUse composable [`useEventSource`](https://vueuse.org/core/useeventsource/).
|
|
775
775
|
::
|
|
776
776
|
|
|
777
777
|
When consuming SSE via POST request, you need to handle the connection manually. Here's how you can do it:
|
|
@@ -6,7 +6,7 @@ navigation.icon: i-lucide-database
|
|
|
6
6
|
|
|
7
7
|
Nuxt provides the [`useState`](/docs/4.x/api/composables/use-state) composable to create a reactive and SSR-friendly shared state across components.
|
|
8
8
|
|
|
9
|
-
[`useState`](/docs/4.x/api/composables/use-state) is an SSR-friendly [`ref`](https://vuejs.org/api/reactivity-core
|
|
9
|
+
[`useState`](/docs/4.x/api/composables/use-state) is an SSR-friendly [`ref`](https://vuejs.org/api/reactivity-core#ref) replacement. Its value will be preserved after server-side rendering (during client-side hydration) and shared across all components using a unique key.
|
|
10
10
|
|
|
11
11
|
:video-accordion{title="Watch a video from Alexander Lichter about why and when to use useState" videoId="mv0WcBABcIk"}
|
|
12
12
|
|
|
@@ -61,7 +61,7 @@ To globally invalidate cached state, see [`clearNuxtState`](/docs/4.x/api/utils/
|
|
|
61
61
|
|
|
62
62
|
### Initializing State
|
|
63
63
|
|
|
64
|
-
Most of the time, you will want to initialize your state with data that resolves asynchronously. You can use the [`app.vue`](/docs/4.x/guide/directory-structure/app) component with the [`callOnce`](/docs/4.x/api/utils/call-once) util to do so.
|
|
64
|
+
Most of the time, you will want to initialize your state with data that resolves asynchronously. You can use the [`app.vue`](/docs/4.x/guide/directory-structure/app/app) component with the [`callOnce`](/docs/4.x/api/utils/call-once) util to do so.
|
|
65
65
|
|
|
66
66
|
```vue twoslash [app/app.vue]
|
|
67
67
|
<script setup lang="ts">
|
|
@@ -17,11 +17,11 @@ Nuxt is a full-stack framework, which means there are several sources of unpreve
|
|
|
17
17
|
|
|
18
18
|
## Vue Errors
|
|
19
19
|
|
|
20
|
-
You can hook into Vue errors using [`onErrorCaptured`](https://vuejs.org/api/composition-api-lifecycle
|
|
20
|
+
You can hook into Vue errors using [`onErrorCaptured`](https://vuejs.org/api/composition-api-lifecycle#onerrorcaptured).
|
|
21
21
|
|
|
22
22
|
In addition, Nuxt provides a [`vue:error`](/docs/4.x/api/advanced/hooks#app-hooks-runtime) hook that will be called if any errors propagate up to the top level.
|
|
23
23
|
|
|
24
|
-
If you are using an error reporting framework, you can provide a global handler through [`vueApp.config.errorHandler`](https://vuejs.org/api/application
|
|
24
|
+
If you are using an error reporting framework, you can provide a global handler through [`vueApp.config.errorHandler`](https://vuejs.org/api/application#app-config-errorhandler). It will receive all Vue errors, even if they are handled.
|
|
25
25
|
|
|
26
26
|
```ts twoslash [plugins/error-handler.ts]
|
|
27
27
|
export default defineNuxtPlugin((nuxtApp) => {
|
|
@@ -37,7 +37,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
::note
|
|
40
|
-
Note that the `vue:error` hook is based on [`onErrorCaptured`](https://vuejs.org/api/composition-api-lifecycle
|
|
40
|
+
Note that the `vue:error` hook is based on [`onErrorCaptured`](https://vuejs.org/api/composition-api-lifecycle#onerrorcaptured) lifecycle hook.
|
|
41
41
|
::
|
|
42
42
|
|
|
43
43
|
## Startup Errors
|
|
@@ -45,7 +45,7 @@ Note that the `vue:error` hook is based on [`onErrorCaptured`](https://vuejs.org
|
|
|
45
45
|
Nuxt will call the `app:error` hook if there are any errors in starting your Nuxt application.
|
|
46
46
|
|
|
47
47
|
This includes:
|
|
48
|
-
- running [Nuxt plugins](/docs/4.x/guide/directory-structure/plugins)
|
|
48
|
+
- running [Nuxt plugins](/docs/4.x/guide/directory-structure/app/plugins)
|
|
49
49
|
- processing `app:created` and `app:beforeMount` hooks
|
|
50
50
|
- rendering your Vue app to HTML (during SSR)
|
|
51
51
|
- mounting the app (on client-side), though you should handle this case with `onErrorCaptured` or with `vue:error`
|
|
@@ -49,14 +49,14 @@ Nitro offers the ability to deploy your Nuxt app anywhere, from a bare metal ser
|
|
|
49
49
|
There are more than 15 presets to build your Nuxt app for different cloud providers and servers, including:
|
|
50
50
|
|
|
51
51
|
- [Cloudflare Workers](https://workers.cloudflare.com)
|
|
52
|
-
- [Netlify Functions](https://www.netlify.com/
|
|
53
|
-
- [Vercel
|
|
52
|
+
- [Netlify Functions](https://www.netlify.com/platform/core/functions/)
|
|
53
|
+
- [Vercel Cloud](https://vercel.com/home)
|
|
54
54
|
|
|
55
55
|
Or for other runtimes:
|
|
56
56
|
|
|
57
57
|
::card-group
|
|
58
|
-
:card{icon="i-logos-deno" title="Deno" to="https://deno.
|
|
59
|
-
:card{icon="i-logos-bun" title="Bun" to="https://bun.
|
|
58
|
+
:card{icon="i-logos-deno" title="Deno" to="https://deno.com" target="_blank"}
|
|
59
|
+
:card{icon="i-logos-bun" title="Bun" to="https://bun.com" target="_blank"}
|
|
60
60
|
::
|
|
61
61
|
|
|
62
62
|
:read-more{to="/docs/4.x/getting-started/deployment"}
|
|
@@ -76,7 +76,7 @@ export default defineNuxtConfig({
|
|
|
76
76
|
|
|
77
77
|
::
|
|
78
78
|
|
|
79
|
-
Nuxt uses [unjs/c12](https://
|
|
79
|
+
Nuxt uses [unjs/c12](https://github.com/unjs/c12) and [unjs/giget](https://github.com/unjs/giget) for extending remote layers. Check the documentation for more information and all available options.
|
|
80
80
|
|
|
81
81
|
## Layer Priority
|
|
82
82
|
|
|
@@ -265,7 +265,7 @@ it('can also mount an app', async () => {
|
|
|
265
265
|
|
|
266
266
|
`renderSuspended` allows you to render any Vue component within the Nuxt environment using `@testing-library/vue`, allowing async setup and access to injections from your Nuxt plugins.
|
|
267
267
|
|
|
268
|
-
This should be used together with utilities from Testing Library, e.g. `screen` and `fireEvent`. Install [@testing-library/vue](https://testing-library.com/docs/vue-testing-library/intro) in your project to use these.
|
|
268
|
+
This should be used together with utilities from Testing Library, e.g. `screen` and `fireEvent`. Install [@testing-library/vue](https://testing-library.com/docs/vue-testing-library/intro/) in your project to use these.
|
|
269
269
|
|
|
270
270
|
Additionally, Testing Library also relies on testing globals for cleanup. You should turn these on in your [Vitest config](https://vitest.dev/config/#globals).
|
|
271
271
|
|
|
@@ -330,10 +330,10 @@ mockNuxtImport('useStorage', () => {
|
|
|
330
330
|
```
|
|
331
331
|
|
|
332
332
|
::note
|
|
333
|
-
`mockNuxtImport` can only be used once per mocked import per test file. It is actually a macro that gets transformed to `vi.mock` and `vi.mock` is hoisted, as described [in the Vitest docs](https://vitest.dev/api/vi
|
|
333
|
+
`mockNuxtImport` can only be used once per mocked import per test file. It is actually a macro that gets transformed to `vi.mock` and `vi.mock` is hoisted, as described [in the Vitest docs](https://vitest.dev/api/vi#vi-mock).
|
|
334
334
|
::
|
|
335
335
|
|
|
336
|
-
If you need to mock a Nuxt import and provide different implementations between tests, you can do it by creating and exposing your mocks using [`vi.hoisted`](https://vitest.dev/api/vi
|
|
336
|
+
If you need to mock a Nuxt import and provide different implementations between tests, you can do it by creating and exposing your mocks using [`vi.hoisted`](https://vitest.dev/api/vi#vi-hoisted), and then use those mocks in `mockNuxtImport`. You then have access to the mocked imports, and can change the implementation between tests. Be careful to [restore mocks](https://vitest.dev/api/mock#mockrestore) before or after each test to undo mock state changes between runs.
|
|
337
337
|
|
|
338
338
|
```ts twoslash
|
|
339
339
|
import { vi } from 'vitest'
|
|
@@ -54,7 +54,7 @@ export default defineNuxtConfig({
|
|
|
54
54
|
|
|
55
55
|
When you set your `future.compatibilityVersion` to `5`, defaults throughout your Nuxt configuration will change to opt in to Nuxt v5 behavior, including:
|
|
56
56
|
|
|
57
|
-
- **Vite Environment API**: Automatically enables the new [Vite Environment API](#migration-to-vite-environment-api) for improved build configuration
|
|
57
|
+
- **Vite Environment API**: Automatically enables the new [Vite Environment API](/docs/4.x/getting-started/upgrade#migration-to-vite-environment-api) for improved build configuration
|
|
58
58
|
- Other Nuxt 5 improvements and changes as they become available
|
|
59
59
|
|
|
60
60
|
::note
|
|
@@ -74,7 +74,7 @@ Nuxt 5 migrates to Vite 6's new [Environment API](https://vite.dev/guide/api-env
|
|
|
74
74
|
Previously, Nuxt used separate client and server Vite configurations. Now, Nuxt uses a shared Vite configuration with environment-specific plugins that use the `applyToEnvironment()` method to target specific environments.
|
|
75
75
|
|
|
76
76
|
::tip
|
|
77
|
-
You can test this feature early by setting `future.compatibilityVersion: 5` (see [Testing Nuxt 5](#testing-nuxt-5)) or by enabling it explicitly with `experimental.viteEnvironmentApi: true`.
|
|
77
|
+
You can test this feature early by setting `future.compatibilityVersion: 5` (see [Testing Nuxt 5](/docs/4.x/getting-started/upgrade#testing-nuxt-5)) or by enabling it explicitly with `experimental.viteEnvironmentApi: true`.
|
|
78
78
|
::
|
|
79
79
|
|
|
80
80
|
**Key changes:**
|
|
@@ -214,7 +214,7 @@ To facilitate the upgrade process, we have collaborated with the [Codemod](https
|
|
|
214
214
|
If you encounter any issues, please report them to the Codemod team with `npx codemod feedback` 🙏
|
|
215
215
|
::
|
|
216
216
|
|
|
217
|
-
For a complete list of Nuxt 4 codemods, detailed information on each, their source, and various ways to run them, visit the [Codemod Registry](https://
|
|
217
|
+
For a complete list of Nuxt 4 codemods, detailed information on each, their source, and various ways to run them, visit the [Codemod Registry](https://app.codemod.com/registry).
|
|
218
218
|
|
|
219
219
|
You can run all the codemods mentioned in this guide using the following `codemod` recipe:
|
|
220
220
|
|
|
@@ -163,7 +163,7 @@ Read more about the options for `hydrate-on-visible`.
|
|
|
163
163
|
::
|
|
164
164
|
|
|
165
165
|
::note
|
|
166
|
-
Under the hood, this uses Vue's built-in [`hydrateOnVisible` strategy](https://vuejs.org/guide/components/async
|
|
166
|
+
Under the hood, this uses Vue's built-in [`hydrateOnVisible` strategy](https://vuejs.org/guide/components/async#hydrate-on-visible).
|
|
167
167
|
::
|
|
168
168
|
|
|
169
169
|
#### `hydrate-on-idle`
|
|
@@ -181,7 +181,7 @@ You can also pass a number which serves as a max timeout.
|
|
|
181
181
|
```
|
|
182
182
|
|
|
183
183
|
::note
|
|
184
|
-
Under the hood, this uses Vue's built-in [`hydrateOnIdle` strategy](https://vuejs.org/guide/components/async
|
|
184
|
+
Under the hood, this uses Vue's built-in [`hydrateOnIdle` strategy](https://vuejs.org/guide/components/async#hydrate-on-idle).
|
|
185
185
|
::
|
|
186
186
|
|
|
187
187
|
#### `hydrate-on-interaction`
|
|
@@ -199,7 +199,7 @@ Hydrates the component after a specified interaction (e.g., click, mouseover).
|
|
|
199
199
|
If you do not pass an event or list of events, it defaults to hydrating on `pointerenter`, `click` and `focus`.
|
|
200
200
|
|
|
201
201
|
::note
|
|
202
|
-
Under the hood, this uses Vue's built-in [`hydrateOnInteraction` strategy](https://vuejs.org/guide/components/async
|
|
202
|
+
Under the hood, this uses Vue's built-in [`hydrateOnInteraction` strategy](https://vuejs.org/guide/components/async#hydrate-on-interaction).
|
|
203
203
|
::
|
|
204
204
|
|
|
205
205
|
#### `hydrate-on-media-query`
|
|
@@ -215,7 +215,7 @@ Hydrates the component when the window matches a media query.
|
|
|
215
215
|
```
|
|
216
216
|
|
|
217
217
|
::note
|
|
218
|
-
Under the hood, this uses Vue's built-in [`hydrateOnMediaQuery` strategy](https://vuejs.org/guide/components/async
|
|
218
|
+
Under the hood, this uses Vue's built-in [`hydrateOnMediaQuery` strategy](https://vuejs.org/guide/components/async#hydrate-on-media-query).
|
|
219
219
|
::
|
|
220
220
|
|
|
221
221
|
#### `hydrate-after`
|
|
@@ -71,7 +71,7 @@ export const useFoo = () => {
|
|
|
71
71
|
|
|
72
72
|
### Access plugin injections
|
|
73
73
|
|
|
74
|
-
You can access [plugin injections](/docs/4.x/guide/directory-structure/plugins#providing-helpers) from composables:
|
|
74
|
+
You can access [plugin injections](/docs/4.x/guide/directory-structure/app/plugins#providing-helpers) from composables:
|
|
75
75
|
|
|
76
76
|
```ts [app/composables/test.ts]
|
|
77
77
|
export const useHello = () => {
|
|
@@ -11,7 +11,7 @@ For best performance, components placed in this directory will be automatically
|
|
|
11
11
|
|
|
12
12
|
## Enable Layouts
|
|
13
13
|
|
|
14
|
-
Layouts are enabled by adding [`<NuxtLayout>`](/docs/4.x/api/components/nuxt-layout) to your [`app.vue`](/docs/4.x/guide/directory-structure/app):
|
|
14
|
+
Layouts are enabled by adding [`<NuxtLayout>`](/docs/4.x/api/components/nuxt-layout) to your [`app.vue`](/docs/4.x/guide/directory-structure/app/app):
|
|
15
15
|
|
|
16
16
|
```vue [app/app.vue]
|
|
17
17
|
<template>
|
|
@@ -34,7 +34,7 @@ If no layout is specified, `app/layouts/default.vue` will be used.
|
|
|
34
34
|
::
|
|
35
35
|
|
|
36
36
|
::important
|
|
37
|
-
If you only have a single layout in your application, we recommend using [`app.vue`](/docs/4.x/guide/directory-structure/app) instead.
|
|
37
|
+
If you only have a single layout in your application, we recommend using [`app.vue`](/docs/4.x/guide/directory-structure/app/app) instead.
|
|
38
38
|
::
|
|
39
39
|
|
|
40
40
|
::important
|
|
@@ -48,13 +48,13 @@ Nuxt provides two globally available helpers that can be returned directly from
|
|
|
48
48
|
1. [`navigateTo`](/docs/4.x/api/utils/navigate-to) - Redirects to the given route
|
|
49
49
|
2. [`abortNavigation`](/docs/4.x/api/utils/abort-navigation) - Aborts the navigation, with an optional error message.
|
|
50
50
|
|
|
51
|
-
Unlike [navigation guards](https://router.vuejs.org/guide/advanced/navigation-guards
|
|
51
|
+
Unlike [navigation guards](https://router.vuejs.org/guide/advanced/navigation-guards#Global-Before-Guards) from `vue-router`, a third `next()` argument is not passed, and **redirect or route cancellation is handled by returning a value from the middleware**.
|
|
52
52
|
|
|
53
53
|
Possible return values are:
|
|
54
54
|
|
|
55
55
|
* nothing (a simple `return` or no return at all) - does not block navigation and will move to the next middleware function, if any, or complete the route navigation
|
|
56
|
-
* `return navigateTo('/')` - redirects to the given path and will set the redirect code to [`302` Found](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302) if the redirect happens on the server side
|
|
57
|
-
* `return navigateTo('/', { redirectCode: 301 })` - redirects to the given path and will set the redirect code to [`301` Moved Permanently](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/301) if the redirect happens on the server side
|
|
56
|
+
* `return navigateTo('/')` - redirects to the given path and will set the redirect code to [`302` Found](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/302) if the redirect happens on the server side
|
|
57
|
+
* `return navigateTo('/', { redirectCode: 301 })` - redirects to the given path and will set the redirect code to [`301` Moved Permanently](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/301) if the redirect happens on the server side
|
|
58
58
|
* `return abortNavigation()` - stops the current navigation
|
|
59
59
|
* `return abortNavigation(error)` - rejects the current navigation with an error
|
|
60
60
|
|
|
@@ -62,7 +62,7 @@ Possible return values are:
|
|
|
62
62
|
:read-more{to="/docs/4.x/api/utils/abort-navigation"}
|
|
63
63
|
|
|
64
64
|
::important
|
|
65
|
-
We recommend using the helper functions above for performing redirects or stopping navigation. Other possible return values described in [the vue-router docs](https://router.vuejs.org/guide/advanced/navigation-guards
|
|
65
|
+
We recommend using the helper functions above for performing redirects or stopping navigation. Other possible return values described in [the vue-router docs](https://router.vuejs.org/guide/advanced/navigation-guards#Global-Before-Guards) may work but there may be breaking changes in future.
|
|
66
66
|
::
|
|
67
67
|
|
|
68
68
|
## Middleware Order
|
|
@@ -6,12 +6,12 @@ navigation.icon: i-vscode-icons-folder-type-view
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
::note
|
|
9
|
-
To reduce your application's bundle size, this directory is **optional**, meaning that [`vue-router`](https://router.vuejs.org) won't be included if you only use [`app.vue`](/docs/4.x/guide/directory-structure/app). To force the pages system, set `pages: true` in `nuxt.config` or have a [`router.options.ts`](/docs/4.x/guide/recipes/custom-routing#using-routeroptions).
|
|
9
|
+
To reduce your application's bundle size, this directory is **optional**, meaning that [`vue-router`](https://router.vuejs.org) won't be included if you only use [`app.vue`](/docs/4.x/guide/directory-structure/app/app). To force the pages system, set `pages: true` in `nuxt.config` or have a [`router.options.ts`](/docs/4.x/guide/recipes/custom-routing#using-routeroptions).
|
|
10
10
|
::
|
|
11
11
|
|
|
12
12
|
## Usage
|
|
13
13
|
|
|
14
|
-
Pages are Vue components and can have any [valid extension](/docs/4.x/api/
|
|
14
|
+
Pages are Vue components and can have any [valid extension](/docs/4.x/api/nuxt-config#extensions) that Nuxt supports (by default `.vue`, `.js`, `.jsx`, `.mjs`, `.ts` or `.tsx`).
|
|
15
15
|
|
|
16
16
|
Nuxt will automatically create a route for every page in your `~/pages/` directory.
|
|
17
17
|
|
|
@@ -46,7 +46,7 @@ export default defineComponent({
|
|
|
46
46
|
|
|
47
47
|
The `app/pages/index.vue` file will be mapped to the `/` route of your application.
|
|
48
48
|
|
|
49
|
-
If you are using [`app.vue`](/docs/4.x/guide/directory-structure/app), make sure to use the [`<NuxtPage/>`](/docs/4.x/api/components/nuxt-page) component to display the current page:
|
|
49
|
+
If you are using [`app.vue`](/docs/4.x/guide/directory-structure/app/app), make sure to use the [`<NuxtPage/>`](/docs/4.x/api/components/nuxt-page) component to display the current page:
|
|
50
50
|
|
|
51
51
|
```vue [app/app.vue]
|
|
52
52
|
<template>
|
|
@@ -93,7 +93,7 @@ Here are some examples to illustrate what a page with a single root element look
|
|
|
93
93
|
|
|
94
94
|
## Dynamic Routes
|
|
95
95
|
|
|
96
|
-
If you place anything within square brackets, it will be turned into a [dynamic route](https://router.vuejs.org/guide/essentials/dynamic-matching
|
|
96
|
+
If you place anything within square brackets, it will be turned into a [dynamic route](https://router.vuejs.org/guide/essentials/dynamic-matching) parameter. You can mix and match multiple parameters and even non-dynamic text within a file name or directory.
|
|
97
97
|
|
|
98
98
|
If you want a parameter to be _optional_, you must enclose it in double square brackets - for example, `~/pages/[[slug]]/index.vue` or `~/pages/[[slug]].vue` will match both `/` and `/test`.
|
|
99
99
|
|
|
@@ -154,7 +154,7 @@ Navigating to `/hello/world` would render:
|
|
|
154
154
|
|
|
155
155
|
## Nested Routes
|
|
156
156
|
|
|
157
|
-
It is possible to display [nested routes](https://
|
|
157
|
+
It is possible to display [nested routes](https://router.vuejs.org/guide/essentials/nested-routes) with `<NuxtPage>`.
|
|
158
158
|
|
|
159
159
|
Example:
|
|
160
160
|
|
|
@@ -268,9 +268,9 @@ console.log(route.meta.title) // My home page
|
|
|
268
268
|
</script>
|
|
269
269
|
```
|
|
270
270
|
|
|
271
|
-
If you are using nested routes, the page metadata from all these routes will be merged into a single object. For more on route meta, see the [vue-router docs](https://router.vuejs.org/guide/advanced/meta
|
|
271
|
+
If you are using nested routes, the page metadata from all these routes will be merged into a single object. For more on route meta, see the [vue-router docs](https://router.vuejs.org/guide/advanced/meta).
|
|
272
272
|
|
|
273
|
-
Much like `defineEmits` or `defineProps` (see [Vue docs](https://vuejs.org/api/sfc-script-setup
|
|
273
|
+
Much like `defineEmits` or `defineProps` (see [Vue docs](https://vuejs.org/api/sfc-script-setup#defineprops-defineemits)), `definePageMeta` is a **compiler macro**. It will be compiled away so you cannot reference it within your component. Instead, the metadata passed to it will be hoisted out of the component.
|
|
274
274
|
Therefore, the page meta object cannot reference the component. However, it can reference imported bindings, as well as locally defined **pure functions**.
|
|
275
275
|
|
|
276
276
|
::warning
|
|
@@ -301,13 +301,13 @@ Of course, you are welcome to define metadata for your own use throughout your a
|
|
|
301
301
|
|
|
302
302
|
#### `alias`
|
|
303
303
|
|
|
304
|
-
You can define page aliases. They allow you to access the same page from different paths. It can be either a string or an array of strings as defined [in the vue-router documentation](https://router.vuejs.org/guide/essentials/redirect-and-alias
|
|
304
|
+
You can define page aliases. They allow you to access the same page from different paths. It can be either a string or an array of strings as defined [in the vue-router documentation](https://router.vuejs.org/guide/essentials/redirect-and-alias#Alias).
|
|
305
305
|
|
|
306
306
|
#### `keepalive`
|
|
307
307
|
|
|
308
|
-
Nuxt will automatically wrap your page in [the Vue `<KeepAlive>` component](https://vuejs.org/guide/built-ins/keep-alive
|
|
308
|
+
Nuxt will automatically wrap your page in [the Vue `<KeepAlive>` component](https://vuejs.org/guide/built-ins/keep-alive#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.
|
|
309
309
|
|
|
310
|
-
When your goal is to preserve state for parent routes use this syntax: `<NuxtPage keepalive />`. You can also set props to be passed to `<KeepAlive>` (see [a full list](https://vuejs.org/api/built-in-components
|
|
310
|
+
When your goal is to preserve state for parent routes use this syntax: `<NuxtPage keepalive />`. You can also set props to be passed to `<KeepAlive>` (see [a full list](https://vuejs.org/api/built-in-components#keepalive)).
|
|
311
311
|
|
|
312
312
|
You can set a default value for this property [in your `nuxt.config`](/docs/4.x/api/nuxt-config#keepalive).
|
|
313
313
|
|
|
@@ -321,13 +321,13 @@ You can define the layout used to render the route. This can be either false (to
|
|
|
321
321
|
|
|
322
322
|
#### `layoutTransition` and `pageTransition`
|
|
323
323
|
|
|
324
|
-
You can define transition properties for the `<transition>` component that wraps your pages and layouts, or pass `false` to disable the `<transition>` wrapper for that route. You can see [a list of options that can be passed](https://vuejs.org/api/built-in-components
|
|
324
|
+
You can define transition properties for the `<transition>` component that wraps your pages and layouts, or pass `false` to disable the `<transition>` wrapper for that route. You can see [a list of options that can be passed](https://vuejs.org/api/built-in-components#transition) or read [more about how transitions work](https://vuejs.org/guide/built-ins/transition#transition).
|
|
325
325
|
|
|
326
326
|
You can set default values for these properties [in your `nuxt.config`](/docs/4.x/api/nuxt-config#layouttransition).
|
|
327
327
|
|
|
328
328
|
#### `middleware`
|
|
329
329
|
|
|
330
|
-
You can define middleware to apply before loading this page. It will be merged with all the other middleware used in any matching parent/child routes. It can be a string, a function (an anonymous/inlined middleware function following [the global before guard pattern](https://router.vuejs.org/guide/advanced/navigation-guards
|
|
330
|
+
You can define middleware to apply before loading this page. It will be merged with all the other middleware used in any matching parent/child routes. It can be a string, a function (an anonymous/inlined middleware function following [the global before guard pattern](https://router.vuejs.org/guide/advanced/navigation-guards#Global-Before-Guards)), or an array of strings/functions. [More about named middleware](/docs/4.x/guide/directory-structure/app/middleware).
|
|
331
331
|
|
|
332
332
|
#### `name`
|
|
333
333
|
|
|
@@ -335,7 +335,7 @@ You may define a name for this page's route.
|
|
|
335
335
|
|
|
336
336
|
#### `path`
|
|
337
337
|
|
|
338
|
-
You may define a path matcher, if you have a more complex pattern than can be expressed with the file name. See [the `vue-router` docs](https://router.vuejs.org/guide/essentials/route-matching-syntax
|
|
338
|
+
You may define a path matcher, if you have a more complex pattern than can be expressed with the file name. See [the `vue-router` docs](https://router.vuejs.org/guide/essentials/route-matching-syntax#Custom-regex-in-params) for more information.
|
|
339
339
|
|
|
340
340
|
#### `props`
|
|
341
341
|
|
|
@@ -205,7 +205,7 @@ Note that we highly recommend using [`composables`](/docs/4.x/guide/directory-st
|
|
|
205
205
|
|
|
206
206
|
::warning
|
|
207
207
|
**If your plugin provides a `ref` or `computed`, it will not be unwrapped in a component `<template>`.** :br
|
|
208
|
-
This is due to how Vue works with refs that aren't top-level to the template. You can read more about it [in the Vue documentation](https://vuejs.org/guide/essentials/reactivity-fundamentals
|
|
208
|
+
This is due to how Vue works with refs that aren't top-level to the template. You can read more about it [in the Vue documentation](https://vuejs.org/guide/essentials/reactivity-fundamentals#caveat-when-unwrapping-in-templates).
|
|
209
209
|
::
|
|
210
210
|
|
|
211
211
|
## Typing Plugins
|
|
@@ -5,7 +5,7 @@ head.title: "node_modules/"
|
|
|
5
5
|
navigation.icon: i-vscode-icons-folder-type-node
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
The package manager ([`npm`](https://docs.npmjs.com/cli/commands/npm) or [`yarn`](https://yarnpkg.com) or [`pnpm`](https://pnpm.io/cli/install) or [`bun`](https://bun.
|
|
8
|
+
The package manager ([`npm`](https://docs.npmjs.com/cli/commands/npm) or [`yarn`](https://yarnpkg.com) or [`pnpm`](https://pnpm.io/cli/install) or [`bun`](https://bun.com/package-manager)) creates this directory to store the dependencies of your project.
|
|
9
9
|
|
|
10
10
|
::important
|
|
11
11
|
This directory should be added to your [`.gitignore`](/docs/4.x/guide/directory-structure/gitignore) file to avoid pushing the dependencies to your repository.
|
|
@@ -22,6 +22,6 @@ useSeoMeta({
|
|
|
22
22
|
</script>
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
::tip{to="https://v2.nuxt.com/docs/directory-structure/static" target="_blank"}
|
|
25
|
+
::tip{to="https://v2.nuxt.com/docs/directory-structure/static/" target="_blank"}
|
|
26
26
|
This is known as the [`static/`] directory in Nuxt 2.
|
|
27
27
|
::
|