@nuxt/docs-nightly 4.1.3-29300098.2f71703a → 4.1.3-29303775.dc69e26c
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/01.introduction.md +2 -2
- package/1.getting-started/03.configuration.md +10 -10
- package/1.getting-started/04.views.md +6 -6
- package/1.getting-started/05.assets.md +7 -7
- package/1.getting-started/06.styling.md +5 -5
- package/1.getting-started/07.routing.md +8 -8
- package/1.getting-started/08.seo-meta.md +10 -10
- package/1.getting-started/09.transitions.md +11 -11
- package/1.getting-started/10.data-fetching.md +36 -36
- package/1.getting-started/11.state-management.md +7 -7
- package/1.getting-started/12.error-handling.md +9 -9
- package/1.getting-started/14.layers.md +3 -3
- package/1.getting-started/15.prerendering.md +4 -4
- package/1.getting-started/16.deployment.md +2 -2
- package/1.getting-started/17.testing.md +3 -3
- package/1.getting-started/18.upgrade.md +3 -3
- package/2.guide/1.concepts/1.auto-imports.md +8 -8
- package/2.guide/1.concepts/10.nuxt-lifecycle.md +10 -10
- package/2.guide/1.concepts/2.vuejs-development.md +4 -4
- package/2.guide/1.concepts/3.rendering.md +9 -9
- package/2.guide/1.concepts/4.server-engine.md +5 -5
- package/2.guide/1.concepts/5.modules.md +2 -2
- package/2.guide/1.concepts/7.esm.md +3 -3
- package/2.guide/1.concepts/8.typescript.md +8 -8
- package/2.guide/2.directory-structure/0.nuxt.md +2 -2
- package/2.guide/2.directory-structure/0.output.md +2 -2
- package/2.guide/2.directory-structure/1.app/1.assets.md +2 -2
- package/2.guide/2.directory-structure/1.app/1.components.md +5 -5
- package/2.guide/2.directory-structure/1.app/1.composables.md +3 -3
- package/2.guide/2.directory-structure/1.app/1.layouts.md +6 -6
- package/2.guide/2.directory-structure/1.app/1.middleware.md +7 -7
- package/2.guide/2.directory-structure/1.app/1.pages.md +14 -14
- package/2.guide/2.directory-structure/1.app/1.plugins.md +7 -7
- package/2.guide/2.directory-structure/1.app/1.utils.md +3 -3
- package/2.guide/2.directory-structure/1.app/3.app-config.md +5 -5
- package/2.guide/2.directory-structure/1.app/3.app.md +3 -3
- package/2.guide/2.directory-structure/1.app/3.error.md +1 -1
- package/2.guide/2.directory-structure/1.content.md +2 -2
- package/2.guide/2.directory-structure/1.modules.md +2 -2
- package/2.guide/2.directory-structure/1.node_modules.md +1 -1
- package/2.guide/2.directory-structure/1.server.md +5 -5
- package/2.guide/2.directory-structure/1.shared.md +2 -2
- package/2.guide/2.directory-structure/2.env.md +4 -4
- package/2.guide/2.directory-structure/2.nuxtignore.md +3 -3
- package/2.guide/2.directory-structure/2.nuxtrc.md +2 -2
- package/2.guide/2.directory-structure/3.nuxt-config.md +1 -1
- package/2.guide/2.directory-structure/3.tsconfig.md +2 -2
- package/2.guide/3.going-further/1.experimental-features.md +9 -9
- package/2.guide/3.going-further/1.internals.md +10 -10
- package/2.guide/3.going-further/10.runtime-config.md +4 -4
- package/2.guide/3.going-further/2.hooks.md +3 -3
- package/2.guide/3.going-further/3.modules.md +16 -16
- package/2.guide/3.going-further/4.kit.md +2 -2
- package/2.guide/3.going-further/6.nuxt-app.md +4 -4
- package/2.guide/3.going-further/7.layers.md +11 -11
- package/2.guide/4.recipes/1.custom-routing.md +11 -11
- package/2.guide/4.recipes/2.vite-plugin.md +1 -1
- package/2.guide/4.recipes/3.custom-usefetch.md +3 -3
- package/2.guide/4.recipes/4.sessions-and-authentication.md +1 -1
- package/2.guide/5.best-practices/hydration.md +4 -4
- package/2.guide/5.best-practices/performance.md +4 -4
- package/3.api/1.components/10.nuxt-picture.md +1 -1
- package/3.api/1.components/12.nuxt-route-announcer.md +2 -2
- package/3.api/1.components/2.nuxt-page.md +2 -2
- package/3.api/1.components/3.nuxt-layout.md +2 -2
- package/3.api/1.components/4.nuxt-link.md +3 -3
- package/3.api/1.components/5.nuxt-loading-indicator.md +2 -2
- package/3.api/2.composables/use-async-data.md +6 -6
- package/3.api/2.composables/use-cookie.md +2 -2
- package/3.api/2.composables/use-fetch.md +4 -4
- package/3.api/2.composables/use-head-safe.md +2 -2
- package/3.api/2.composables/use-head.md +2 -2
- package/3.api/2.composables/use-hydration.md +1 -1
- package/3.api/2.composables/use-lazy-async-data.md +2 -2
- package/3.api/2.composables/use-lazy-fetch.md +2 -2
- package/3.api/2.composables/use-loading-indicator.md +2 -2
- package/3.api/2.composables/use-nuxt-app.md +12 -12
- package/3.api/2.composables/use-nuxt-data.md +1 -1
- package/3.api/2.composables/use-preview-mode.md +3 -3
- package/3.api/2.composables/use-request-event.md +1 -1
- package/3.api/2.composables/use-request-fetch.md +2 -2
- package/3.api/2.composables/use-request-header.md +1 -1
- package/3.api/2.composables/use-request-headers.md +1 -1
- package/3.api/2.composables/use-request-url.md +1 -1
- package/3.api/2.composables/use-response-header.md +2 -2
- package/3.api/2.composables/use-route-announcer.md +1 -1
- package/3.api/2.composables/use-route.md +1 -1
- package/3.api/2.composables/use-router.md +4 -4
- package/3.api/2.composables/use-runtime-hook.md +1 -1
- package/3.api/2.composables/use-seo-meta.md +1 -1
- package/3.api/2.composables/use-server-seo-meta.md +3 -3
- package/3.api/2.composables/use-state.md +1 -1
- package/3.api/3.utils/$fetch.md +4 -4
- package/3.api/3.utils/abort-navigation.md +1 -1
- package/3.api/3.utils/add-route-middleware.md +2 -2
- package/3.api/3.utils/call-once.md +1 -1
- package/3.api/3.utils/clear-error.md +1 -1
- package/3.api/3.utils/clear-nuxt-data.md +1 -1
- package/3.api/3.utils/clear-nuxt-state.md +1 -1
- package/3.api/3.utils/define-nuxt-plugin.md +3 -3
- package/3.api/3.utils/define-nuxt-route-middleware.md +3 -3
- package/3.api/3.utils/define-page-meta.md +8 -8
- package/3.api/3.utils/define-route-rules.md +2 -2
- package/3.api/3.utils/navigate-to.md +1 -1
- package/3.api/3.utils/prefetch-components.md +1 -1
- package/3.api/3.utils/prerender-routes.md +1 -1
- package/3.api/3.utils/refresh-nuxt-data.md +2 -2
- package/3.api/3.utils/set-page-layout.md +1 -1
- package/3.api/3.utils/set-response-status.md +1 -1
- package/3.api/3.utils/show-error.md +2 -2
- package/3.api/3.utils/update-app-config.md +1 -1
- package/3.api/4.commands/module.md +2 -2
- package/3.api/4.commands/prepare.md +1 -1
- package/3.api/4.commands/preview.md +2 -2
- package/3.api/4.commands/typecheck.md +1 -1
- package/3.api/5.kit/10.runtime-config.md +1 -1
- package/3.api/5.kit/3.compatibility.md +2 -2
- package/3.api/5.kit/4.autoimports.md +1 -1
- package/3.api/5.kit/5.components.md +2 -2
- package/3.api/5.kit/7.pages.md +3 -3
- package/3.api/5.kit/8.layout.md +1 -1
- package/3.api/6.advanced/1.hooks.md +2 -2
- package/3.api/6.nuxt-config.md +4 -4
- package/5.community/2.getting-help.md +1 -1
- package/5.community/3.reporting-bugs.md +1 -1
- package/5.community/4.contribution.md +10 -10
- package/5.community/5.framework-contribution.md +4 -4
- package/5.community/6.roadmap.md +1 -1
- package/6.bridge/1.overview.md +12 -12
- package/6.bridge/2.typescript.md +1 -1
- package/6.bridge/3.bridge-composition-api.md +5 -5
- package/6.bridge/4.plugins-and-middleware.md +4 -4
- package/6.bridge/5.nuxt3-compatible-api.md +9 -9
- package/6.bridge/6.meta.md +5 -5
- package/6.bridge/7.runtime-config.md +1 -1
- package/6.bridge/8.nitro.md +1 -1
- package/6.bridge/9.vite.md +1 -1
- package/7.migration/1.overview.md +2 -2
- package/7.migration/2.configuration.md +5 -5
- package/7.migration/20.module-authors.md +6 -6
- package/7.migration/3.auto-imports.md +3 -3
- package/7.migration/4.meta.md +3 -3
- package/7.migration/6.pages-and-layouts.md +8 -8
- package/7.migration/7.component-options.md +11 -11
- package/7.migration/8.runtime-config.md +3 -3
- package/package.json +1 -1
|
@@ -6,12 +6,12 @@ navigation.icon: i-lucide-folder
|
|
|
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/guide/directory-structure/app). To force the pages system, set `pages: true` in `nuxt.config` or have a [`router.options.ts`](/docs/guide/recipes/custom-routing#using-
|
|
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).
|
|
10
10
|
::
|
|
11
11
|
|
|
12
12
|
## Usage
|
|
13
13
|
|
|
14
|
-
Pages are Vue components and can have any [valid extension](/docs/api/configuration/nuxt-config#extensions) that Nuxt supports (by default `.vue`, `.js`, `.jsx`, `.mjs`, `.ts` or `.tsx`).
|
|
14
|
+
Pages are Vue components and can have any [valid extension](/docs/4.x/api/configuration/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/guide/directory-structure/app), make sure to use the [`<NuxtPage/>`](/docs/api/components/nuxt-page) component to display the current page:
|
|
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:
|
|
50
50
|
|
|
51
51
|
```vue [app/app.vue]
|
|
52
52
|
<template>
|
|
@@ -57,7 +57,7 @@ If you are using [`app.vue`](/docs/guide/directory-structure/app), make sure to
|
|
|
57
57
|
</template>
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
Pages **must have a single root element** to allow [route transitions](/docs/getting-started/transitions) between pages. HTML comments are considered elements as well.
|
|
60
|
+
Pages **must have a single root element** to allow [route transitions](/docs/4.x/getting-started/transitions) between pages. HTML comments are considered elements as well.
|
|
61
61
|
|
|
62
62
|
This means that when the route is server-rendered, or statically generated, you will be able to see its contents correctly, but when you navigate towards that route during client-side navigation the transition between routes will fail and you'll see that the route will not be rendered.
|
|
63
63
|
|
|
@@ -118,7 +118,7 @@ Navigating to `/users-admins/123` would render:
|
|
|
118
118
|
<p>admins - 123</p>
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
-
If you want to access the route using Composition API, there is a global [`useRoute`](/docs/api/composables/use-route) function that will allow you to access the route just like `this.$route` in the Options API.
|
|
121
|
+
If you want to access the route using Composition API, there is a global [`useRoute`](/docs/4.x/api/composables/use-route) function that will allow you to access the route just like `this.$route` in the Options API.
|
|
122
122
|
|
|
123
123
|
```vue twoslash
|
|
124
124
|
<script setup lang="ts">
|
|
@@ -307,25 +307,25 @@ Nuxt will automatically wrap your page in [the Vue `<KeepAlive>` component](http
|
|
|
307
307
|
|
|
308
308
|
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.html#keepalive)).
|
|
309
309
|
|
|
310
|
-
You can set a default value for this property [in your `nuxt.config`](/docs/api/nuxt-config#keepalive).
|
|
310
|
+
You can set a default value for this property [in your `nuxt.config`](/docs/4.x/api/nuxt-config#keepalive).
|
|
311
311
|
|
|
312
312
|
#### `key`
|
|
313
313
|
|
|
314
|
-
[See above](#child-route-keys).
|
|
314
|
+
[See above](/docs/guide/directory-structure/app/pages#child-route-keys).
|
|
315
315
|
|
|
316
316
|
#### `layout`
|
|
317
317
|
|
|
318
|
-
You can define the layout used to render the route. This can be either false (to disable any layout), a string or a ref/computed, if you want to make it reactive in some way. [More about layouts](/docs/guide/directory-structure/app/layouts).
|
|
318
|
+
You can define the layout used to render the route. This can be either false (to disable any layout), a string or a ref/computed, if you want to make it reactive in some way. [More about layouts](/docs/4.x/guide/directory-structure/app/layouts).
|
|
319
319
|
|
|
320
320
|
#### `layoutTransition` and `pageTransition`
|
|
321
321
|
|
|
322
322
|
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.html#transition) or read [more about how transitions work](https://vuejs.org/guide/built-ins/transition.html#transition).
|
|
323
323
|
|
|
324
|
-
You can set default values for these properties [in your `nuxt.config`](/docs/api/nuxt-config#layouttransition).
|
|
324
|
+
You can set default values for these properties [in your `nuxt.config`](/docs/4.x/api/nuxt-config#layouttransition).
|
|
325
325
|
|
|
326
326
|
#### `middleware`
|
|
327
327
|
|
|
328
|
-
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.html#global-before-guards)), or an array of strings/functions. [More about named middleware](/docs/guide/directory-structure/app/middleware).
|
|
328
|
+
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.html#global-before-guards)), or an array of strings/functions. [More about named middleware](/docs/4.x/guide/directory-structure/app/middleware).
|
|
329
329
|
|
|
330
330
|
#### `name`
|
|
331
331
|
|
|
@@ -356,7 +356,7 @@ export {}
|
|
|
356
356
|
|
|
357
357
|
## Navigation
|
|
358
358
|
|
|
359
|
-
To navigate between pages of your app, you should use the [`<NuxtLink>`](/docs/api/components/nuxt-link) component.
|
|
359
|
+
To navigate between pages of your app, you should use the [`<NuxtLink>`](/docs/4.x/api/components/nuxt-link) component.
|
|
360
360
|
|
|
361
361
|
This component is included with Nuxt and therefore you don't have to import it as you do with other components.
|
|
362
362
|
|
|
@@ -399,11 +399,11 @@ function navigate(){
|
|
|
399
399
|
|
|
400
400
|
## Client-Only Pages
|
|
401
401
|
|
|
402
|
-
You can define a page as [client only](/docs/guide/directory-structure/app/components#client-components) by giving it a `.client.vue` suffix. None of the content of this page will be rendered on the server.
|
|
402
|
+
You can define a page as [client only](/docs/4.x/guide/directory-structure/app/components#client-components) by giving it a `.client.vue` suffix. None of the content of this page will be rendered on the server.
|
|
403
403
|
|
|
404
404
|
## Server-Only Pages
|
|
405
405
|
|
|
406
|
-
You can define a page as [server only](/docs/guide/directory-structure/app/components#server-components) by giving it a `.server.vue` suffix. While you will be able to navigate to the page using client-side navigation, controlled by `vue-router`, it will be rendered with a server component automatically, meaning the code required to render the page will not be in your client-side bundle.
|
|
406
|
+
You can define a page as [server only](/docs/4.x/guide/directory-structure/app/components#server-components) by giving it a `.server.vue` suffix. While you will be able to navigate to the page using client-side navigation, controlled by `vue-router`, it will be rendered with a server component automatically, meaning the code required to render the page will not be in your client-side bundle.
|
|
407
407
|
|
|
408
408
|
::warning
|
|
409
409
|
Server-only pages must have a single root element. (HTML comments are considered elements as well.)
|
|
@@ -419,7 +419,7 @@ As your app gets bigger and more complex, your routing might require more flexib
|
|
|
419
419
|
|
|
420
420
|
By default, all your pages should be in one `app/pages` directory at the root of your project.
|
|
421
421
|
|
|
422
|
-
However, you can use [Nuxt Layers](/docs/getting-started/layers) to create groupings of your app's pages:
|
|
422
|
+
However, you can use [Nuxt Layers](/docs/4.x/getting-started/layers) to create groupings of your app's pages:
|
|
423
423
|
|
|
424
424
|
```bash [Directory Structure]
|
|
425
425
|
-| some-app/
|
|
@@ -30,7 +30,7 @@ Only files at the top level of the directory (or index files within any subdirec
|
|
|
30
30
|
|
|
31
31
|
Only `foo.ts` and `bar/index.ts` would be registered.
|
|
32
32
|
|
|
33
|
-
To add plugins in subdirectories, you can use the [`app/plugins`](/docs/api/nuxt-config#plugins-1) option in `nuxt.config.ts`:
|
|
33
|
+
To add plugins in subdirectories, you can use the [`app/plugins`](/docs/4.x/api/nuxt-config#plugins-1) option in `nuxt.config.ts`:
|
|
34
34
|
|
|
35
35
|
```ts twoslash [nuxt.config.ts]
|
|
36
36
|
export default defineNuxtConfig({
|
|
@@ -43,7 +43,7 @@ export default defineNuxtConfig({
|
|
|
43
43
|
|
|
44
44
|
## Creating Plugins
|
|
45
45
|
|
|
46
|
-
The only argument passed to a plugin is [`nuxtApp`](/docs/api/composables/use-nuxt-app).
|
|
46
|
+
The only argument passed to a plugin is [`nuxtApp`](/docs/4.x/api/composables/use-nuxt-app).
|
|
47
47
|
|
|
48
48
|
```ts twoslash [plugins/hello.ts]
|
|
49
49
|
export default defineNuxtPlugin(nuxtApp => {
|
|
@@ -134,7 +134,7 @@ export default defineNuxtPlugin({
|
|
|
134
134
|
|
|
135
135
|
## Using Composables
|
|
136
136
|
|
|
137
|
-
You can use [composables](/docs/guide/directory-structure/app/composables) as well as [utils](/docs/guide/directory-structure/app/utils) within Nuxt plugins:
|
|
137
|
+
You can use [composables](/docs/4.x/guide/directory-structure/app/composables) as well as [utils](/docs/4.x/guide/directory-structure/app/utils) within Nuxt plugins:
|
|
138
138
|
|
|
139
139
|
```ts [app/plugins/hello.ts]
|
|
140
140
|
export default defineNuxtPlugin((nuxtApp) => {
|
|
@@ -153,12 +153,12 @@ Plugins are called in order sequentially and before everything else. You might u
|
|
|
153
153
|
::important
|
|
154
154
|
**If a composable depends on the Vue.js lifecycle, it won't work.** :br
|
|
155
155
|
|
|
156
|
-
Normally, Vue.js composables are bound to the current component instance while plugins are only bound to [`nuxtApp`](/docs/api/composables/use-nuxt-app) instance.
|
|
156
|
+
Normally, Vue.js composables are bound to the current component instance while plugins are only bound to [`nuxtApp`](/docs/4.x/api/composables/use-nuxt-app) instance.
|
|
157
157
|
::
|
|
158
158
|
|
|
159
159
|
## Providing Helpers
|
|
160
160
|
|
|
161
|
-
If you would like to provide a helper on the [`NuxtApp`](/docs/api/composables/use-nuxt-app) instance, return it from the plugin under a `provide` key.
|
|
161
|
+
If you would like to provide a helper on the [`NuxtApp`](/docs/4.x/api/composables/use-nuxt-app) instance, return it from the plugin under a `provide` key.
|
|
162
162
|
|
|
163
163
|
::code-group
|
|
164
164
|
```ts twoslash [plugins/hello.ts]
|
|
@@ -200,7 +200,7 @@ const { $hello } = useNuxtApp()
|
|
|
200
200
|
```
|
|
201
201
|
|
|
202
202
|
::important
|
|
203
|
-
Note that we highly recommend using [`composables`](/docs/guide/directory-structure/app/composables) instead of providing helpers to avoid polluting the global namespace and keep your main bundle entry small.
|
|
203
|
+
Note that we highly recommend using [`composables`](/docs/4.x/guide/directory-structure/app/composables) instead of providing helpers to avoid polluting the global namespace and keep your main bundle entry small.
|
|
204
204
|
::
|
|
205
205
|
|
|
206
206
|
::warning
|
|
@@ -213,7 +213,7 @@ This is due to how Vue works with refs that aren't top-level to the template. Yo
|
|
|
213
213
|
If you return your helpers from the plugin, they will be typed automatically; you'll find them typed for the return of `useNuxtApp()` and within your templates.
|
|
214
214
|
|
|
215
215
|
::note
|
|
216
|
-
If you need to use a provided helper _within_ another plugin, you can call [`useNuxtApp()`](/docs/api/composables/use-nuxt-app) to get the typed version. But in general, this should be avoided unless you are certain of the plugins' order.
|
|
216
|
+
If you need to use a provided helper _within_ another plugin, you can call [`useNuxtApp()`](/docs/4.x/api/composables/use-nuxt-app) to get the typed version. But in general, this should be avoided unless you are certain of the plugins' order.
|
|
217
217
|
::
|
|
218
218
|
|
|
219
219
|
For advanced use-cases, you can declare the type of injected properties like this:
|
|
@@ -5,7 +5,7 @@ description: Use the utils/ directory to auto-import your utility functions thro
|
|
|
5
5
|
navigation.icon: i-lucide-folder
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
The main purpose of the [`app/utils/` directory](/docs/guide/directory-structure/app/utils) is to allow a semantic distinction between your Vue composables and other auto-imported utility functions.
|
|
8
|
+
The main purpose of the [`app/utils/` directory](/docs/4.x/guide/directory-structure/app/utils) is to allow a semantic distinction between your Vue composables and other auto-imported utility functions.
|
|
9
9
|
|
|
10
10
|
## Usage
|
|
11
11
|
|
|
@@ -40,10 +40,10 @@ You can now use auto imported utility functions in `.js`, `.ts` and `.vue` files
|
|
|
40
40
|
:link-example{to="/docs/examples/features/auto-imports"}
|
|
41
41
|
|
|
42
42
|
::tip
|
|
43
|
-
The way `app/utils/` auto-imports work and are scanned is identical to the [`app/composables/`](/docs/guide/directory-structure/app/composables) directory.
|
|
43
|
+
The way `app/utils/` auto-imports work and are scanned is identical to the [`app/composables/`](/docs/4.x/guide/directory-structure/app/composables) directory.
|
|
44
44
|
::
|
|
45
45
|
|
|
46
46
|
::important
|
|
47
47
|
These utils are only available within the Vue part of your app. :br
|
|
48
|
-
Only `server/utils` are auto-imported in the [`server/`](/docs/guide/directory-structure/server#server-utilities) directory.
|
|
48
|
+
Only `server/utils` are auto-imported in the [`server/`](/docs/4.x/guide/directory-structure/server#server-utilities) directory.
|
|
49
49
|
::
|
|
@@ -20,7 +20,7 @@ Do not put any secret values inside `app.config` file. It is exposed to the user
|
|
|
20
20
|
::
|
|
21
21
|
|
|
22
22
|
::note
|
|
23
|
-
When configuring a custom [`srcDir`](/docs/api/nuxt-config#srcdir), make sure to place the `app.config` file at the root of the new `srcDir` path.
|
|
23
|
+
When configuring a custom [`srcDir`](/docs/4.x/api/nuxt-config#srcdir), make sure to place the `app.config` file at the root of the new `srcDir` path.
|
|
24
24
|
::
|
|
25
25
|
|
|
26
26
|
## Usage
|
|
@@ -35,7 +35,7 @@ export default defineAppConfig({
|
|
|
35
35
|
})
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
We can now universally access `theme` both when server-rendering the page and in the browser using [`useAppConfig`](/docs/api/composables/use-app-config) composable.
|
|
38
|
+
We can now universally access `theme` both when server-rendering the page and in the browser using [`useAppConfig`](/docs/4.x/api/composables/use-app-config) composable.
|
|
39
39
|
|
|
40
40
|
```vue [app/pages/index.vue]
|
|
41
41
|
<script setup lang="ts">
|
|
@@ -45,7 +45,7 @@ console.log(appConfig.theme)
|
|
|
45
45
|
</script>
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
The [`updateAppConfig`](/docs/api/utils/update-app-config) utility can be used to update the `app.config` at runtime.
|
|
48
|
+
The [`updateAppConfig`](/docs/4.x/api/utils/update-app-config) utility can be used to update the `app.config` at runtime.
|
|
49
49
|
|
|
50
50
|
```vue [app/pages/index.vue]
|
|
51
51
|
<script setup>
|
|
@@ -90,7 +90,7 @@ export {}
|
|
|
90
90
|
|
|
91
91
|
### App Config Output
|
|
92
92
|
|
|
93
|
-
If you want to type the result of calling [`useAppConfig()`](/docs/api/composables/use-app-config), then you will want to extend `AppConfig`.
|
|
93
|
+
If you want to type the result of calling [`useAppConfig()`](/docs/4.x/api/composables/use-app-config), then you will want to extend `AppConfig`.
|
|
94
94
|
|
|
95
95
|
::warning
|
|
96
96
|
Be careful when typing `AppConfig` as you will overwrite the types Nuxt infers from your actually defined app config.
|
|
@@ -114,7 +114,7 @@ export {}
|
|
|
114
114
|
|
|
115
115
|
## Merging Strategy
|
|
116
116
|
|
|
117
|
-
Nuxt uses a custom merging strategy for the `AppConfig` within [the layers](/docs/getting-started/layers) of your application.
|
|
117
|
+
Nuxt uses a custom merging strategy for the `AppConfig` within [the layers](/docs/4.x/getting-started/layers) of your application.
|
|
118
118
|
|
|
119
119
|
This strategy is implemented using a [Function Merger](https://github.com/unjs/defu#function-merger), which allows defining a custom merging strategy for every key in `app.config` that has an array as value.
|
|
120
120
|
|
|
@@ -13,7 +13,7 @@ If you have a `app/pages/` directory, the `app.vue` file is optional. Nuxt will
|
|
|
13
13
|
|
|
14
14
|
### Minimal Usage
|
|
15
15
|
|
|
16
|
-
With Nuxt, the [`app/pages/`](/docs/guide/directory-structure/app/pages) directory is optional. If it is not present, Nuxt will not include the [vue-router](https://router.vuejs.org) dependency. This is useful when building a landing page or an application that does not require routing.
|
|
16
|
+
With Nuxt, the [`app/pages/`](/docs/4.x/guide/directory-structure/app/pages) directory is optional. If it is not present, Nuxt will not include the [vue-router](https://router.vuejs.org) dependency. This is useful when building a landing page or an application that does not require routing.
|
|
17
17
|
|
|
18
18
|
```vue [app/app.vue]
|
|
19
19
|
<template>
|
|
@@ -25,7 +25,7 @@ With Nuxt, the [`app/pages/`](/docs/guide/directory-structure/app/pages) directo
|
|
|
25
25
|
|
|
26
26
|
### Usage with Pages
|
|
27
27
|
|
|
28
|
-
When you have a [`app/pages/`](/docs/guide/directory-structure/app/pages) directory, you need to use the [`<NuxtPage>`](/docs/api/components/nuxt-page) component to display the current page:
|
|
28
|
+
When you have a [`app/pages/`](/docs/4.x/guide/directory-structure/app/pages) directory, you need to use the [`<NuxtPage>`](/docs/4.x/api/components/nuxt-page) component to display the current page:
|
|
29
29
|
|
|
30
30
|
```vue [app/app.vue]
|
|
31
31
|
<template>
|
|
@@ -57,7 +57,7 @@ Learn more about how to structure your pages using the `app/pages/` directory.
|
|
|
57
57
|
|
|
58
58
|
### Usage with Layouts
|
|
59
59
|
|
|
60
|
-
When your application requires different layouts for different pages, you can use the `app/layouts/` directory with the [`<NuxtLayout>`](/docs/api/components/nuxt-layout) component. This allows you to define multiple layouts and apply them per page.
|
|
60
|
+
When your application requires different layouts for different pages, you can use the `app/layouts/` directory with the [`<NuxtLayout>`](/docs/4.x/api/components/nuxt-layout) component. This allows you to define multiple layouts and apply them per page.
|
|
61
61
|
|
|
62
62
|
```vue [app/app.vue]
|
|
63
63
|
<template>
|
|
@@ -25,7 +25,7 @@ const props = defineProps({
|
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
::note
|
|
28
|
-
Although it is called an 'error page' it's not a route and shouldn't be placed in your `~/pages` directory. For the same reason, you shouldn't use `definePageMeta` within this page. That being said, you can still use layouts in the error file, by utilizing the [`NuxtLayout`](/docs/api/components/nuxt-layout) component and specifying the name of the layout.
|
|
28
|
+
Although it is called an 'error page' it's not a route and shouldn't be placed in your `~/pages` directory. For the same reason, you shouldn't use `definePageMeta` within this page. That being said, you can still use layouts in the error file, by utilizing the [`NuxtLayout`](/docs/4.x/api/components/nuxt-layout) component and specifying the name of the layout.
|
|
29
29
|
::
|
|
30
30
|
|
|
31
31
|
The error page has a single prop - `error` which contains an error for you to handle.
|
|
@@ -5,7 +5,7 @@ description: Use the content/ directory to create a file-based CMS for your appl
|
|
|
5
5
|
navigation.icon: i-lucide-folder
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
[Nuxt Content](https://content.nuxt.com) reads the [`content/` directory](/docs/guide/directory-structure/content) in your project and parses `.md`, `.yml`, `.csv` and `.json` files to create a file-based CMS for your application.
|
|
8
|
+
[Nuxt Content](https://content.nuxt.com) reads the [`content/` directory](/docs/4.x/guide/directory-structure/content) in your project and parses `.md`, `.yml`, `.csv` and `.json` files to create a file-based CMS for your application.
|
|
9
9
|
|
|
10
10
|
- Render your content with built-in components.
|
|
11
11
|
- Query your content with a MongoDB-like API.
|
|
@@ -36,7 +36,7 @@ The module automatically loads and parses them.
|
|
|
36
36
|
|
|
37
37
|
## Render Content
|
|
38
38
|
|
|
39
|
-
To render content pages, add a [catch-all route](/docs/guide/directory-structure/app/pages/#catch-all-route) using the [`<ContentRenderer>`](https://content.nuxt.com/docs/components/content-renderer) component:
|
|
39
|
+
To render content pages, add a [catch-all route](/docs/4.x/guide/directory-structure/app/pages/#catch-all-route) using the [`<ContentRenderer>`](https://content.nuxt.com/docs/components/content-renderer) component:
|
|
40
40
|
|
|
41
41
|
```vue [app/pages/[...slug\\].vue]
|
|
42
42
|
<script lang="ts" setup>
|
|
@@ -11,7 +11,7 @@ The auto-registered files patterns are:
|
|
|
11
11
|
- `modules/*/index.ts`
|
|
12
12
|
- `modules/*.ts`
|
|
13
13
|
|
|
14
|
-
You don't need to add those local modules to your [`nuxt.config.ts`](/docs/guide/directory-structure/nuxt-config) separately.
|
|
14
|
+
You don't need to add those local modules to your [`nuxt.config.ts`](/docs/4.x/guide/directory-structure/nuxt-config) separately.
|
|
15
15
|
|
|
16
16
|
::code-group
|
|
17
17
|
|
|
@@ -47,7 +47,7 @@ export default defineEventHandler(() => {
|
|
|
47
47
|
When starting Nuxt, the `hello` module will be registered and the `/api/hello` route will be available.
|
|
48
48
|
|
|
49
49
|
Modules are executed in the following sequence:
|
|
50
|
-
- First, the modules defined in [`nuxt.config.ts`](/docs/api/nuxt-config#modules-1) are loaded.
|
|
50
|
+
- First, the modules defined in [`nuxt.config.ts`](/docs/4.x/api/nuxt-config#modules-1) are loaded.
|
|
51
51
|
- Then, modules found in the `modules/` directory are executed, and they load in alphabetical order.
|
|
52
52
|
|
|
53
53
|
You can change the order of local module by adding a number to the front of each directory name:
|
|
@@ -8,5 +8,5 @@ navigation.icon: i-lucide-folder
|
|
|
8
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.sh/package-manager)) creates this directory to store the dependencies of your project.
|
|
9
9
|
|
|
10
10
|
::important
|
|
11
|
-
This directory should be added to your [`.gitignore`](/docs/guide/directory-structure/gitignore) file to avoid pushing the dependencies to your repository.
|
|
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.
|
|
12
12
|
::
|
|
@@ -58,7 +58,7 @@ export default defineEventHandler(() => 'Hello World!')
|
|
|
58
58
|
Given the example above, the `/hello` route will be accessible at <http://localhost:3000/hello>.
|
|
59
59
|
|
|
60
60
|
::note
|
|
61
|
-
Note that currently server routes do not support the full functionality of dynamic routes as [pages](/docs/guide/directory-structure/app/pages#dynamic-routes) do.
|
|
61
|
+
Note that currently server routes do not support the full functionality of dynamic routes as [pages](/docs/4.x/guide/directory-structure/app/pages#dynamic-routes) do.
|
|
62
62
|
::
|
|
63
63
|
|
|
64
64
|
## Server Middleware
|
|
@@ -269,7 +269,7 @@ If no errors are thrown, a status code of `200 OK` will be returned.
|
|
|
269
269
|
|
|
270
270
|
Any uncaught errors will return a `500 Internal Server Error` HTTP Error.
|
|
271
271
|
|
|
272
|
-
To return other error codes, throw an exception with [`createError`](/docs/api/utils/create-error):
|
|
272
|
+
To return other error codes, throw an exception with [`createError`](/docs/4.x/api/utils/create-error):
|
|
273
273
|
|
|
274
274
|
```ts [server/api/validation/[id\\].ts]
|
|
275
275
|
export default defineEventHandler((event) => {
|
|
@@ -287,7 +287,7 @@ export default defineEventHandler((event) => {
|
|
|
287
287
|
|
|
288
288
|
### Status Codes
|
|
289
289
|
|
|
290
|
-
To return other status codes, use the [`setResponseStatus`](/docs/api/utils/set-response-status) utility.
|
|
290
|
+
To return other status codes, use the [`setResponseStatus`](/docs/4.x/api/utils/set-response-status) utility.
|
|
291
291
|
|
|
292
292
|
For example, to return `202 Accepted`
|
|
293
293
|
|
|
@@ -326,7 +326,7 @@ NUXT_GITHUB_TOKEN='<my-super-token>'
|
|
|
326
326
|
::
|
|
327
327
|
|
|
328
328
|
::note
|
|
329
|
-
Giving the `event` as argument to `useRuntimeConfig` is optional, but it is recommended to pass it to get the runtime config overwritten by [environment variables](/docs/guide/going-further/runtime-config#environment-variables) at runtime for server routes.
|
|
329
|
+
Giving the `event` as argument to `useRuntimeConfig` is optional, but it is recommended to pass it to get the runtime config overwritten by [environment variables](/docs/4.x/guide/going-further/runtime-config#environment-variables) at runtime for server routes.
|
|
330
330
|
::
|
|
331
331
|
|
|
332
332
|
### Request Cookies
|
|
@@ -454,7 +454,7 @@ Never combine `next()` callback with a legacy middleware that is `async` or retu
|
|
|
454
454
|
|
|
455
455
|
### Server Storage
|
|
456
456
|
|
|
457
|
-
Nitro provides a cross-platform [storage layer](https://nitro.build/guide/storage). In order to configure additional storage mount points, you can use `nitro.storage`, or [server plugins](#server-plugins).
|
|
457
|
+
Nitro provides a cross-platform [storage layer](https://nitro.build/guide/storage). In order to configure additional storage mount points, you can use `nitro.storage`, or [server plugins](/docs/guide/directory-structure/server#server-plugins).
|
|
458
458
|
|
|
459
459
|
**Example of adding a Redis storage:**
|
|
460
460
|
|
|
@@ -35,7 +35,7 @@ export default function (input: string) {
|
|
|
35
35
|
}
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
You can now use [auto-imported](/docs/guide/directory-structure/shared
|
|
38
|
+
You can now use [auto-imported](/docs/4.x/guide/directory-structure/shared) utilities in your Nuxt app and `server/` directory.
|
|
39
39
|
|
|
40
40
|
```vue [app/app.vue]
|
|
41
41
|
<script setup lang="ts">
|
|
@@ -62,7 +62,7 @@ export default defineEventHandler((event) => {
|
|
|
62
62
|
Only files in the `shared/utils/` and `shared/types/` directories will be auto-imported. Files nested within subdirectories of these directories will not be auto-imported unless you add these directories to `imports.dirs` and `nitro.imports.dirs`.
|
|
63
63
|
|
|
64
64
|
::tip
|
|
65
|
-
The way `shared/utils` and `shared/types` auto-imports work and are scanned is identical to the [`app/composables/`](/docs/guide/directory-structure/app/composables) and [`app/utils/`](/docs/guide/directory-structure/app/utils) directories.
|
|
65
|
+
The way `shared/utils` and `shared/types` auto-imports work and are scanned is identical to the [`app/composables/`](/docs/4.x/guide/directory-structure/app/composables) and [`app/utils/`](/docs/4.x/guide/directory-structure/app/utils) directories.
|
|
66
66
|
::
|
|
67
67
|
|
|
68
68
|
:read-more{to="/docs/guide/directory-structure/app/composables#how-files-are-scanned"}
|
|
@@ -6,12 +6,12 @@ navigation.icon: i-lucide-file
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
::important
|
|
9
|
-
This file should be added to your [`.gitignore`](/docs/guide/directory-structure/gitignore) file to avoid pushing secrets to your repository.
|
|
9
|
+
This file should be added to your [`.gitignore`](/docs/4.x/guide/directory-structure/gitignore) file to avoid pushing secrets to your repository.
|
|
10
10
|
::
|
|
11
11
|
|
|
12
12
|
## Dev, Build and Generate Time
|
|
13
13
|
|
|
14
|
-
Nuxt CLI has built-in [dotenv](https://github.com/motdotla/dotenv) support in development mode and when running [`nuxt build`](/docs/api/commands/build) and [`nuxt generate`](/docs/api/commands/generate).
|
|
14
|
+
Nuxt CLI has built-in [dotenv](https://github.com/motdotla/dotenv) support in development mode and when running [`nuxt build`](/docs/4.x/api/commands/build) and [`nuxt generate`](/docs/4.x/api/commands/generate).
|
|
15
15
|
|
|
16
16
|
In addition to any process environment variables, if you have a `.env` file in your project root directory, it will be automatically loaded **at dev, build and generate time**. Any environment variables set there will be accessible within your `nuxt.config` file and modules.
|
|
17
17
|
|
|
@@ -34,7 +34,7 @@ npx nuxt dev --dotenv .env.local
|
|
|
34
34
|
When updating `.env` in development mode, the Nuxt instance is automatically restarted to apply new values to the `process.env`.
|
|
35
35
|
|
|
36
36
|
::important
|
|
37
|
-
In your application code, you should use [Runtime Config](/docs/guide/going-further/runtime-config) instead of plain env variables.
|
|
37
|
+
In your application code, you should use [Runtime Config](/docs/4.x/guide/going-further/runtime-config) instead of plain env variables.
|
|
38
38
|
::
|
|
39
39
|
|
|
40
40
|
## Production
|
|
@@ -61,7 +61,7 @@ Since `.env` files are not used in production, you must explicitly set environme
|
|
|
61
61
|
|
|
62
62
|
## Production Preview
|
|
63
63
|
|
|
64
|
-
For local production preview purpose, we recommend using [`nuxt preview`](/docs/api/commands/preview) since using this command, the `.env` file will be loaded into `process.env` for convenience. Note that this command requires dependencies to be installed in the package directory.
|
|
64
|
+
For local production preview purpose, we recommend using [`nuxt preview`](/docs/4.x/api/commands/preview) since using this command, the `.env` file will be loaded into `process.env` for convenience. Note that this command requires dependencies to be installed in the package directory.
|
|
65
65
|
|
|
66
66
|
Or you could pass the environment variables as arguments using the terminal. For example, on Linux or macOS:
|
|
67
67
|
|
|
@@ -5,12 +5,12 @@ description: The .nuxtignore file lets Nuxt ignore files in your project’s roo
|
|
|
5
5
|
navigation.icon: i-lucide-file
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
The `.nuxtignore` file tells Nuxt to ignore files in your project’s root directory ([`rootDir`](/docs/api/nuxt-config#rootdir)) during the build phase.
|
|
8
|
+
The `.nuxtignore` file tells Nuxt to ignore files in your project’s root directory ([`rootDir`](/docs/4.x/api/nuxt-config#rootdir)) during the build phase.
|
|
9
9
|
|
|
10
|
-
It is subject to the same specification as [`.gitignore`](/docs/guide/directory-structure/gitignore) and `.eslintignore` files, in which each line is a glob pattern indicating which files should be ignored.
|
|
10
|
+
It is subject to the same specification as [`.gitignore`](/docs/4.x/guide/directory-structure/gitignore) and `.eslintignore` files, in which each line is a glob pattern indicating which files should be ignored.
|
|
11
11
|
|
|
12
12
|
::tip
|
|
13
|
-
You can also configure [`ignoreOptions`](/docs/api/nuxt-config#ignoreoptions), [`ignorePrefix`](/docs/api/nuxt-config#ignoreprefix) and [`ignore`](/docs/api/nuxt-config#ignore) in your `nuxt.config` file.
|
|
13
|
+
You can also configure [`ignoreOptions`](/docs/4.x/api/nuxt-config#ignoreoptions), [`ignorePrefix`](/docs/4.x/api/nuxt-config#ignoreprefix) and [`ignore`](/docs/4.x/api/nuxt-config#ignore) in your `nuxt.config` file.
|
|
14
14
|
::
|
|
15
15
|
|
|
16
16
|
## Usage
|
|
@@ -8,7 +8,7 @@ navigation.icon: i-lucide-file
|
|
|
8
8
|
The `.nuxtrc` file can be used to configure Nuxt with a flat syntax. It is based on [`unjs/rc9`](https://github.com/unjs/rc9).
|
|
9
9
|
|
|
10
10
|
::tip
|
|
11
|
-
For more advanced configurations, use [`nuxt.config`](/docs/guide/directory-structure/nuxt-config).
|
|
11
|
+
For more advanced configurations, use [`nuxt.config`](/docs/4.x/guide/directory-structure/nuxt-config).
|
|
12
12
|
::
|
|
13
13
|
|
|
14
14
|
## Usage
|
|
@@ -28,7 +28,7 @@ modules[]=nuxt-security
|
|
|
28
28
|
If present, the properties in the `nuxt.config` file will overwrite the properties in `.nuxtrc` file.
|
|
29
29
|
|
|
30
30
|
::note
|
|
31
|
-
Nuxt automatically adds a `setups` section to track module installation and upgrade state. This is used internally for [module lifecycle hooks](/docs/api/kit/modules#using-lifecycle-hooks-for-module-installation-and-upgrade) and should not be modified manually.
|
|
31
|
+
Nuxt automatically adds a `setups` section to track module installation and upgrade state. This is used internally for [module lifecycle hooks](/docs/4.x/api/kit/modules#using-lifecycle-hooks-for-module-installation-and-upgrade) and should not be modified manually.
|
|
32
32
|
::
|
|
33
33
|
|
|
34
34
|
::read-more{to="/docs/api/configuration/nuxt-config"}
|
|
@@ -31,4 +31,4 @@ export default defineNuxtConfig({
|
|
|
31
31
|
Discover all the available options in the **Nuxt configuration** documentation.
|
|
32
32
|
::
|
|
33
33
|
|
|
34
|
-
To ensure your configuration is up to date, Nuxt will make a full restart when detecting changes in the main configuration file, the [`.env`](/docs/guide/directory-structure/env), [`.nuxtignore`](/docs/guide/directory-structure/nuxtignore) and [`.nuxtrc`](/docs/guide/directory-structure/nuxtrc) dotfiles.
|
|
34
|
+
To ensure your configuration is up to date, Nuxt will make a full restart when detecting changes in the main configuration file, the [`.env`](/docs/4.x/guide/directory-structure/env), [`.nuxtignore`](/docs/4.x/guide/directory-structure/nuxtignore) and [`.nuxtrc`](/docs/4.x/guide/directory-structure/nuxtrc) dotfiles.
|
|
@@ -5,7 +5,7 @@ head.title: "tsconfig.json"
|
|
|
5
5
|
navigation.icon: i-lucide-file
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
Nuxt [automatically generates](/docs/guide/concepts/typescript) multiple TypeScript configuration files (`.nuxt/tsconfig.app.json`, `.nuxt/tsconfig.server.json`, `.nuxt/tsconfig.node.json` and `.nuxt/tsconfig.shared.json`) with the resolved aliases you are using in your Nuxt project, as well as with other sensible defaults.
|
|
8
|
+
Nuxt [automatically generates](/docs/4.x/guide/concepts/typescript) multiple TypeScript configuration files (`.nuxt/tsconfig.app.json`, `.nuxt/tsconfig.server.json`, `.nuxt/tsconfig.node.json` and `.nuxt/tsconfig.shared.json`) with the resolved aliases you are using in your Nuxt project, as well as with other sensible defaults.
|
|
9
9
|
|
|
10
10
|
You can benefit from this by creating a `tsconfig.json` in the root of your project with the following content:
|
|
11
11
|
|
|
@@ -34,5 +34,5 @@ As you need to, you can customize the contents of this file. However, it is reco
|
|
|
34
34
|
::
|
|
35
35
|
|
|
36
36
|
::note
|
|
37
|
-
If you need to customize your `paths`, this will override the auto-generated path aliases. Instead, we recommend that you add any path aliases you need to the [`alias`](/docs/api/nuxt-config#alias) property within your `nuxt.config`, where they will get picked up and added to the auto-generated `tsconfig`.
|
|
37
|
+
If you need to customize your `paths`, this will override the auto-generated path aliases. Instead, we recommend that you add any path aliases you need to the [`alias`](/docs/4.x/api/nuxt-config#alias) property within your `nuxt.config`, where they will get picked up and added to the auto-generated `tsconfig`.
|
|
38
38
|
::
|
|
@@ -5,7 +5,7 @@ description: "Enable Nuxt experimental features to unlock new possibilities."
|
|
|
5
5
|
|
|
6
6
|
Nuxt includes experimental features that you can enable in your configuration file.
|
|
7
7
|
|
|
8
|
-
Internally, Nuxt uses `@nuxt/schema` to define these experimental features. You can refer to the [API documentation](/docs/api/configuration/nuxt-config#experimental) or the [source code](https://github.com/nuxt/nuxt/blob/main/packages/schema/src/config/experimental.ts) for more information.
|
|
8
|
+
Internally, Nuxt uses `@nuxt/schema` to define these experimental features. You can refer to the [API documentation](/docs/4.x/api/configuration/nuxt-config#experimental) or the [source code](https://github.com/nuxt/nuxt/blob/main/packages/schema/src/config/experimental.ts) for more information.
|
|
9
9
|
|
|
10
10
|
::note
|
|
11
11
|
Note that these features are experimental and could be removed or modified in the future.
|
|
@@ -61,7 +61,7 @@ This feature will likely be removed in a near future.
|
|
|
61
61
|
|
|
62
62
|
Emits `app:chunkError` hook when there is an error loading vite/webpack chunks. Default behavior is to perform a reload of the new route on navigation to a new route when a chunk fails to load.
|
|
63
63
|
|
|
64
|
-
If you set this to `'automatic-immediate'` Nuxt will reload the current route immediately, instead of waiting for a navigation. This is useful for chunk errors that are not triggered by navigation, e.g., when your Nuxt app fails to load a [lazy component](/docs/guide/directory-structure/app/components#dynamic-imports). A potential downside of this behavior is undesired reloads, e.g., when your app does not need the chunk that caused the error.
|
|
64
|
+
If you set this to `'automatic-immediate'` Nuxt will reload the current route immediately, instead of waiting for a navigation. This is useful for chunk errors that are not triggered by navigation, e.g., when your Nuxt app fails to load a [lazy component](/docs/4.x/guide/directory-structure/app/components#dynamic-imports). A potential downside of this behavior is undesired reloads, e.g., when your app does not need the chunk that caused the error.
|
|
65
65
|
|
|
66
66
|
You can disable automatic handling by setting this to `false`, or handle chunk errors manually by setting it to `manual`.
|
|
67
67
|
|
|
@@ -75,13 +75,13 @@ export default defineNuxtConfig({
|
|
|
75
75
|
|
|
76
76
|
## restoreState
|
|
77
77
|
|
|
78
|
-
Allows Nuxt app state to be restored from `sessionStorage` when reloading the page after a chunk error or manual [`reloadNuxtApp()`](/docs/api/utils/reload-nuxt-app) call.
|
|
78
|
+
Allows Nuxt app state to be restored from `sessionStorage` when reloading the page after a chunk error or manual [`reloadNuxtApp()`](/docs/4.x/api/utils/reload-nuxt-app) call.
|
|
79
79
|
|
|
80
80
|
To avoid hydration errors, it will be applied only after the Vue app has been mounted, meaning there may be a flicker on initial load.
|
|
81
81
|
|
|
82
82
|
::important
|
|
83
83
|
Consider carefully before enabling this as it can cause unexpected behavior,
|
|
84
|
-
and consider providing explicit keys to [`useState`](/docs/api/composables/use-state) as auto-generated keys may not match across builds.
|
|
84
|
+
and consider providing explicit keys to [`useState`](/docs/4.x/api/composables/use-state) as auto-generated keys may not match across builds.
|
|
85
85
|
::
|
|
86
86
|
|
|
87
87
|
```ts twoslash [nuxt.config.ts]
|
|
@@ -94,7 +94,7 @@ export default defineNuxtConfig({
|
|
|
94
94
|
|
|
95
95
|
## inlineRouteRules
|
|
96
96
|
|
|
97
|
-
Define route rules at the page level using [`defineRouteRules`](/docs/api/utils/define-route-rules).
|
|
97
|
+
Define route rules at the page level using [`defineRouteRules`](/docs/4.x/api/utils/define-route-rules).
|
|
98
98
|
|
|
99
99
|
```ts twoslash [nuxt.config.ts]
|
|
100
100
|
export default defineNuxtConfig({
|
|
@@ -152,7 +152,7 @@ export default defineNuxtConfig({
|
|
|
152
152
|
|
|
153
153
|
## clientFallback
|
|
154
154
|
|
|
155
|
-
Enables the experimental [`<NuxtClientFallback>`](/docs/api/components/nuxt-client-fallback) component for rendering content on the client if there's an error in SSR.
|
|
155
|
+
Enables the experimental [`<NuxtClientFallback>`](/docs/4.x/api/components/nuxt-client-fallback) component for rendering content on the client if there's an error in SSR.
|
|
156
156
|
|
|
157
157
|
```ts twoslash [nuxt.config.ts]
|
|
158
158
|
export default defineNuxtConfig({
|
|
@@ -210,7 +210,7 @@ export default defineNuxtConfig({
|
|
|
210
210
|
|
|
211
211
|
## componentIslands
|
|
212
212
|
|
|
213
|
-
Enables experimental component islands support with [`<NuxtIsland>`](/docs/api/components/nuxt-island) and `.island.vue` files.
|
|
213
|
+
Enables experimental component islands support with [`<NuxtIsland>`](/docs/4.x/api/components/nuxt-island) and `.island.vue` files.
|
|
214
214
|
|
|
215
215
|
```ts twoslash [nuxt.config.ts]
|
|
216
216
|
export default defineNuxtConfig({
|
|
@@ -252,7 +252,7 @@ export default defineNuxtConfig({
|
|
|
252
252
|
})
|
|
253
253
|
```
|
|
254
254
|
|
|
255
|
-
Out of the box, this will enable typed usage of [`navigateTo`](/docs/api/utils/navigate-to), [`<NuxtLink>`](/docs/api/components/nuxt-link), [`router.push()`](/docs/api/composables/use-router) and more.
|
|
255
|
+
Out of the box, this will enable typed usage of [`navigateTo`](/docs/4.x/api/utils/navigate-to), [`<NuxtLink>`](/docs/4.x/api/components/nuxt-link), [`router.push()`](/docs/4.x/api/composables/use-router) and more.
|
|
256
256
|
|
|
257
257
|
You can even get typed params within a page by using `const route = useRoute('route-name')`.
|
|
258
258
|
|
|
@@ -423,7 +423,7 @@ export default defineNuxtConfig({
|
|
|
423
423
|
})
|
|
424
424
|
```
|
|
425
425
|
|
|
426
|
-
This allows modules to access additional metadata from the page metadata in the build context. If you are using this within a module, it's recommended also to [augment the `NuxtPage` types with your keys](/docs/guide/directory-structure/app/pages#typing-custom-metadata).
|
|
426
|
+
This allows modules to access additional metadata from the page metadata in the build context. If you are using this within a module, it's recommended also to [augment the `NuxtPage` types with your keys](/docs/4.x/guide/directory-structure/app/pages#typing-custom-metadata).
|
|
427
427
|
|
|
428
428
|
## normalizeComponentNames
|
|
429
429
|
|
|
@@ -7,15 +7,15 @@ This guide helps you better understand Nuxt internals to develop new solutions a
|
|
|
7
7
|
|
|
8
8
|
## The Nuxt Interface
|
|
9
9
|
|
|
10
|
-
When you start Nuxt in development mode with [`nuxt dev`](/docs/api/commands/dev) or building a production application with [`nuxt build`](/docs/api/commands/build),
|
|
10
|
+
When you start Nuxt in development mode with [`nuxt dev`](/docs/4.x/api/commands/dev) or building a production application with [`nuxt build`](/docs/4.x/api/commands/build),
|
|
11
11
|
a common context will be created, referred to as `nuxt` internally. It holds normalized options merged with `nuxt.config` file,
|
|
12
|
-
some internal state, and a powerful [hooking system](/docs/api/advanced/hooks) powered by [unjs/hookable](https://github.com/unjs/hookable)
|
|
12
|
+
some internal state, and a powerful [hooking system](/docs/4.x/api/advanced/hooks) powered by [unjs/hookable](https://github.com/unjs/hookable)
|
|
13
13
|
allowing different components to communicate with each other. You can think of it as **Builder Core**.
|
|
14
14
|
|
|
15
|
-
This context is globally available to be used with [Nuxt Kit](/docs/guide/going-further/kit) composables.
|
|
15
|
+
This context is globally available to be used with [Nuxt Kit](/docs/4.x/guide/going-further/kit) composables.
|
|
16
16
|
Therefore only one instance of Nuxt is allowed to run per process.
|
|
17
17
|
|
|
18
|
-
To extend the Nuxt interface and hook into different stages of the build process, we can use [Nuxt Modules](/docs/guide/going-further/modules).
|
|
18
|
+
To extend the Nuxt interface and hook into different stages of the build process, we can use [Nuxt Modules](/docs/4.x/guide/going-further/modules).
|
|
19
19
|
|
|
20
20
|
For more details, check out [the source code](https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/core/nuxt.ts).
|
|
21
21
|
|
|
@@ -25,14 +25,14 @@ When rendering a page in the browser or on the server, a shared context will be
|
|
|
25
25
|
This context keeps vue instance, runtime hooks, and internal states like ssrContext and payload for hydration.
|
|
26
26
|
You can think of it as **Runtime Core**.
|
|
27
27
|
|
|
28
|
-
This context can be accessed using [`useNuxtApp()`](/docs/api/composables/use-nuxt-app) composable within Nuxt plugins and `<script setup>` and vue composables.
|
|
28
|
+
This context can be accessed using [`useNuxtApp()`](/docs/4.x/api/composables/use-nuxt-app) composable within Nuxt plugins and `<script setup>` and vue composables.
|
|
29
29
|
Global usage is possible for the browser but not on the server, to avoid sharing context between users.
|
|
30
30
|
|
|
31
|
-
Since [`useNuxtApp`](/docs/api/composables/use-nuxt-app) throws an exception if context is currently unavailable, if your composable does not always require `nuxtApp`, you can use [`tryUseNuxtApp`](/docs/api/composables/use-nuxt-app#tryusenuxtapp) instead, which will return `null` instead of throwing an exception.
|
|
31
|
+
Since [`useNuxtApp`](/docs/4.x/api/composables/use-nuxt-app) throws an exception if context is currently unavailable, if your composable does not always require `nuxtApp`, you can use [`tryUseNuxtApp`](/docs/4.x/api/composables/use-nuxt-app#tryusenuxtapp) instead, which will return `null` instead of throwing an exception.
|
|
32
32
|
|
|
33
|
-
To extend the `nuxtApp` interface and hook into different stages or access contexts, we can use [Nuxt Plugins](/docs/guide/directory-structure/plugins).
|
|
33
|
+
To extend the `nuxtApp` interface and hook into different stages or access contexts, we can use [Nuxt Plugins](/docs/4.x/guide/directory-structure/plugins).
|
|
34
34
|
|
|
35
|
-
Check [Nuxt App](/docs/api/composables/use-nuxt-app) for more information about this interface.
|
|
35
|
+
Check [Nuxt App](/docs/4.x/api/composables/use-nuxt-app) for more information about this interface.
|
|
36
36
|
|
|
37
37
|
`nuxtApp` has the following properties:
|
|
38
38
|
|
|
@@ -76,6 +76,6 @@ Nuxt builds and bundles project using Node.js but also has a runtime side.
|
|
|
76
76
|
|
|
77
77
|
While both areas can be extended, that runtime context is isolated from build-time. Therefore, they are not supposed to share state, code, or context other than runtime configuration!
|
|
78
78
|
|
|
79
|
-
`nuxt.config` and [Nuxt Modules](/docs/guide/going-further/modules) can be used to extend the build context, and [Nuxt Plugins](/docs/guide/directory-structure/plugins) can be used to extend runtime.
|
|
79
|
+
`nuxt.config` and [Nuxt Modules](/docs/4.x/guide/going-further/modules) can be used to extend the build context, and [Nuxt Plugins](/docs/4.x/guide/directory-structure/plugins) can be used to extend runtime.
|
|
80
80
|
|
|
81
|
-
When building an application for production, `nuxt build` will generate a standalone build in the `.output` directory, independent of `nuxt.config` and [Nuxt modules](/docs/guide/going-further/modules).
|
|
81
|
+
When building an application for production, `nuxt build` will generate a standalone build in the `.output` directory, independent of `nuxt.config` and [Nuxt modules](/docs/4.x/guide/going-further/modules).
|