@nuxt/docs-nightly 4.5.1-29752449.30d24817 → 4.5.2-2610052030-052d82e
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 +8 -8
- package/1.getting-started/02.installation.md +2 -4
- package/1.getting-started/03.configuration.md +16 -16
- package/1.getting-started/04.views.md +8 -8
- package/1.getting-started/05.assets.md +10 -10
- package/1.getting-started/06.styling.md +10 -10
- package/1.getting-started/07.routing.md +15 -15
- package/1.getting-started/08.seo-meta.md +15 -15
- package/1.getting-started/09.transitions.md +10 -10
- package/1.getting-started/10.data-fetching.md +61 -47
- package/1.getting-started/11.state-management.md +11 -11
- package/1.getting-started/12.error-handling.md +20 -18
- package/1.getting-started/13.server.md +7 -7
- package/1.getting-started/14.layers.md +6 -6
- package/1.getting-started/15.prerendering.md +22 -28
- package/1.getting-started/16.deployment.md +22 -6
- package/1.getting-started/17.testing.md +200 -21
- package/1.getting-started/18.upgrade.md +78 -278
- package/2.directory-structure/0.nuxt.md +2 -2
- package/2.directory-structure/0.output.md +3 -3
- package/2.directory-structure/1.app/1.assets.md +3 -3
- package/2.directory-structure/1.app/1.components.md +26 -109
- package/2.directory-structure/1.app/1.composables.md +5 -5
- package/2.directory-structure/1.app/1.layouts.md +10 -10
- package/2.directory-structure/1.app/1.middleware.md +14 -10
- package/2.directory-structure/1.app/1.pages.md +25 -20
- package/2.directory-structure/1.app/1.plugins.md +7 -7
- package/2.directory-structure/1.app/1.utils.md +9 -5
- package/2.directory-structure/1.app/3.app-config.md +7 -7
- package/2.directory-structure/1.app/3.app.md +6 -6
- package/2.directory-structure/1.app/3.error.md +1 -1
- package/2.directory-structure/1.content.md +1 -1
- package/2.directory-structure/1.layers.md +13 -13
- package/2.directory-structure/1.modules.md +3 -3
- package/2.directory-structure/1.node_modules.md +1 -1
- package/2.directory-structure/1.server.md +33 -14
- package/2.directory-structure/1.shared.md +7 -5
- package/2.directory-structure/1.test.md +25 -0
- package/2.directory-structure/2.env.md +7 -7
- package/2.directory-structure/2.nuxtignore.md +3 -3
- package/2.directory-structure/2.nuxtrc.md +3 -3
- package/2.directory-structure/3.nuxt-config.md +2 -2
- package/2.directory-structure/3.tsconfig.md +21 -11
- package/2.directory-structure/index.md +29 -25
- package/3.guide/0.index.md +6 -6
- package/3.guide/1.concepts/1.rendering.md +76 -12
- package/3.guide/1.concepts/10.vuejs-development.md +73 -8
- package/3.guide/1.concepts/2.nuxt-lifecycle.md +18 -18
- package/3.guide/1.concepts/3.auto-imports.md +11 -11
- package/3.guide/1.concepts/4.server-engine.md +6 -6
- package/3.guide/1.concepts/5.modules.md +4 -4
- package/3.guide/1.concepts/6.server-components.md +198 -0
- package/3.guide/1.concepts/7.esm.md +5 -5
- package/3.guide/1.concepts/8.typescript.md +9 -9
- package/3.guide/2.best-practices/accessibility.md +155 -0
- package/3.guide/2.best-practices/hydration.md +5 -5
- package/3.guide/2.best-practices/performance.md +13 -9
- package/3.guide/3.ai/1.mcp.md +104 -19
- package/3.guide/4.modules/2.module-anatomy.md +5 -5
- package/3.guide/4.modules/3.recipes-basics.md +8 -8
- package/3.guide/4.modules/4.module-dependencies.md +1 -1
- package/3.guide/4.modules/5.recipes-advanced.md +6 -8
- package/3.guide/4.modules/6.testing.md +2 -2
- package/3.guide/4.modules/7.best-practices.md +2 -2
- package/3.guide/4.modules/9.server-compatibility.md +215 -0
- package/3.guide/4.modules/index.md +9 -9
- package/3.guide/5.recipes/1.custom-routing.md +15 -11
- package/3.guide/5.recipes/2.vite-plugin.md +3 -3
- package/3.guide/5.recipes/3.custom-usefetch.md +5 -5
- package/3.guide/5.recipes/4.sessions-and-authentication.md +2 -2
- package/3.guide/5.recipes/5.mostly-static-sites.md +127 -0
- package/3.guide/6.going-further/1.events.md +1 -1
- package/3.guide/6.going-further/1.experimental-features.md +254 -22
- package/3.guide/6.going-further/1.features.md +42 -6
- package/3.guide/6.going-further/1.internals.md +10 -10
- package/3.guide/6.going-further/10.runtime-config.md +28 -6
- package/3.guide/6.going-further/11.nightly-release-channel.md +1 -1
- package/3.guide/6.going-further/2.hooks.md +6 -6
- package/3.guide/6.going-further/4.kit.md +4 -4
- package/3.guide/6.going-further/5.server-imports.md +221 -0
- package/3.guide/6.going-further/6.nuxt-app.md +7 -7
- package/3.guide/6.going-further/7.layers.md +13 -13
- package/3.guide/6.going-further/8.builders.md +38 -14
- package/4.api/1.components/1.nuxt-client-fallback.md +1 -1
- package/4.api/1.components/10.nuxt-picture.md +1 -1
- package/4.api/1.components/11.teleports.md +1 -1
- package/4.api/1.components/12.nuxt-route-announcer.md +5 -3
- package/4.api/1.components/14.nuxt-announcer.md +3 -3
- package/4.api/1.components/2.nuxt-page.md +5 -5
- package/4.api/1.components/3.nuxt-layout.md +8 -8
- package/4.api/1.components/4.nuxt-link.md +6 -4
- package/4.api/1.components/5.nuxt-loading-indicator.md +3 -3
- package/4.api/1.components/6.nuxt-error-boundary.md +1 -1
- package/4.api/1.components/8.nuxt-island.md +5 -5
- package/4.api/2.composables/create-use-async-data.md +51 -8
- package/4.api/2.composables/create-use-fetch.md +126 -9
- package/4.api/2.composables/use-announcer.md +3 -3
- package/4.api/2.composables/use-app-config.md +1 -1
- package/4.api/2.composables/use-async-data.md +19 -11
- package/4.api/2.composables/use-cookie.md +22 -6
- package/4.api/2.composables/use-error.md +1 -1
- package/4.api/2.composables/use-fetch.md +14 -10
- package/4.api/2.composables/use-head-safe.md +2 -2
- package/4.api/2.composables/use-head.md +2 -2
- package/4.api/2.composables/use-hydration.md +1 -1
- package/4.api/2.composables/use-layout.md +1 -1
- package/4.api/2.composables/use-lazy-async-data.md +8 -8
- package/4.api/2.composables/use-lazy-fetch.md +11 -11
- package/4.api/2.composables/use-loading-indicator.md +2 -2
- package/4.api/2.composables/use-nuxt-app.md +13 -13
- package/4.api/2.composables/use-nuxt-data.md +1 -1
- package/4.api/2.composables/use-preview-mode.md +3 -3
- package/4.api/2.composables/use-request-event.md +29 -3
- package/4.api/2.composables/use-request-fetch.md +2 -2
- package/4.api/2.composables/use-request-header.md +1 -1
- package/4.api/2.composables/use-request-headers.md +1 -1
- package/4.api/2.composables/use-request-url.md +1 -1
- package/4.api/2.composables/use-response-header.md +2 -2
- package/4.api/2.composables/use-route-announcer.md +4 -2
- package/4.api/2.composables/use-route.md +2 -2
- package/4.api/2.composables/use-router.md +5 -5
- package/4.api/2.composables/use-runtime-config.md +5 -5
- package/4.api/2.composables/use-runtime-hook.md +1 -1
- package/4.api/2.composables/use-seo-meta.md +3 -3
- package/4.api/2.composables/use-server-seo-meta.md +5 -5
- package/4.api/2.composables/use-state.md +4 -4
- package/4.api/3.utils/$fetch.md +5 -5
- package/4.api/3.utils/abort-navigation.md +1 -1
- package/4.api/3.utils/add-route-middleware.md +2 -2
- package/4.api/3.utils/call-once.md +3 -3
- package/4.api/3.utils/clear-error.md +2 -2
- package/4.api/3.utils/clear-nuxt-data.md +1 -1
- package/4.api/3.utils/clear-nuxt-state.md +2 -2
- package/4.api/3.utils/create-error.md +19 -1
- package/4.api/3.utils/define-nuxt-plugin.md +2 -2
- package/4.api/3.utils/define-nuxt-route-middleware.md +3 -3
- package/4.api/3.utils/define-page-meta.md +12 -12
- package/4.api/3.utils/define-route-rules.md +4 -4
- package/4.api/3.utils/define-use-async-data-addon.md +57 -0
- package/4.api/3.utils/define-use-fetch-addon.md +168 -0
- package/4.api/3.utils/navigate-to.md +6 -2
- package/4.api/3.utils/prefetch-components.md +1 -1
- package/4.api/3.utils/preload-route-components.md +2 -2
- package/4.api/3.utils/prerender-routes.md +3 -3
- package/4.api/3.utils/refresh-cookie.md +1 -1
- package/4.api/3.utils/refresh-nuxt-data.md +3 -3
- package/4.api/3.utils/reload-nuxt-app.md +1 -1
- package/4.api/3.utils/set-page-layout.md +1 -1
- package/4.api/3.utils/set-response-status.md +2 -2
- package/4.api/3.utils/show-error.md +3 -3
- package/4.api/3.utils/update-app-config.md +2 -2
- package/4.api/4.commands/README.md +9 -0
- package/4.api/5.kit/1.modules.md +3 -3
- package/4.api/5.kit/10.runtime-config.md +1 -1
- package/4.api/5.kit/10.templates.md +42 -0
- package/4.api/5.kit/12.nitro.md +59 -18
- package/4.api/5.kit/14.logging.md +56 -2
- package/4.api/5.kit/15.builder.md +1 -1
- package/4.api/5.kit/18.dependencies.md +90 -0
- package/4.api/5.kit/2.programmatic.md +78 -1
- package/4.api/5.kit/3.compatibility.md +2 -2
- package/4.api/5.kit/4.autoimports.md +13 -13
- package/4.api/5.kit/5.components.md +3 -3
- package/4.api/5.kit/6.context.md +2 -2
- package/4.api/5.kit/7.pages.md +35 -4
- package/4.api/5.kit/8.layout.md +1 -1
- package/4.api/6.advanced/1.hooks.md +6 -3
- package/4.api/6.nuxt-config.md +44 -21
- package/4.api/index.md +7 -7
- package/5.community/2.getting-help.md +1 -1
- package/5.community/3.reporting-bugs.md +1 -1
- package/5.community/4.contribution.md +14 -12
- package/5.community/5.framework-contribution.md +4 -4
- package/5.community/6.roadmap.md +6 -6
- package/6.bridge/1.overview.md +12 -12
- package/6.bridge/2.typescript.md +1 -1
- package/6.bridge/3.bridge-composition-api.md +6 -6
- 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/10.bundling.md +1 -1
- package/7.migration/11.server.md +3 -3
- package/7.migration/2.configuration.md +6 -6
- package/7.migration/20.module-authors.md +7 -7
- package/7.migration/3.auto-imports.md +3 -3
- package/7.migration/4.meta.md +4 -4
- package/7.migration/5.plugins-and-middleware.md +3 -3
- package/7.migration/6.pages-and-layouts.md +13 -13
- package/7.migration/7.component-options.md +15 -15
- package/7.migration/8.runtime-config.md +4 -4
- package/README.md +1 -1
- package/errors/e8007.md +28 -0
- package/package.json +2 -2
- package/4.api/4.commands/.navigation.yml +0 -3
- package/4.api/4.commands/add.md +0 -112
- package/4.api/4.commands/analyze.md +0 -42
- package/4.api/4.commands/build-module.md +0 -42
- package/4.api/4.commands/build.md +0 -48
- package/4.api/4.commands/cleanup.md +0 -38
- package/4.api/4.commands/dev.md +0 -61
- package/4.api/4.commands/devtools.md +0 -38
- package/4.api/4.commands/generate.md +0 -43
- package/4.api/4.commands/info.md +0 -33
- package/4.api/4.commands/init.md +0 -50
- package/4.api/4.commands/module.md +0 -84
- package/4.api/4.commands/prepare.md +0 -41
- package/4.api/4.commands/preview.md +0 -44
- package/4.api/4.commands/test.md +0 -40
- package/4.api/4.commands/typecheck.md +0 -44
- package/4.api/4.commands/upgrade.md +0 -37
|
@@ -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/
|
|
8
|
+
Internally, Nuxt uses `@nuxt/schema` to define these experimental features. You can refer to the [API documentation](/docs/guide/going-further/experimental-features) 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.
|
|
@@ -131,7 +131,7 @@ Emits `app:chunkError` hook when there is an error loading vite/webpack chunks.
|
|
|
131
131
|
|
|
132
132
|
By default, Nuxt will also perform a reload of the new route when a chunk fails to load when navigating to a new route (`automatic`).
|
|
133
133
|
|
|
134
|
-
Setting `automatic-immediate` will lead Nuxt to perform a reload of the current route right when a chunk fails to load (instead of waiting for 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/
|
|
134
|
+
Setting `automatic-immediate` will lead Nuxt to perform a reload of the current route right when a chunk fails to load (instead of waiting for 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/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.
|
|
135
135
|
|
|
136
136
|
You can disable automatic handling by setting this to `false`, or handle chunk errors manually by setting it to `manual`.
|
|
137
137
|
|
|
@@ -159,13 +159,13 @@ export default defineNuxtConfig({
|
|
|
159
159
|
|
|
160
160
|
## restoreState
|
|
161
161
|
|
|
162
|
-
Allows Nuxt app state to be restored from `sessionStorage` when reloading the page after a chunk error or manual [`reloadNuxtApp()`](/docs/
|
|
162
|
+
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.
|
|
163
163
|
|
|
164
164
|
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.
|
|
165
165
|
|
|
166
166
|
::important
|
|
167
167
|
Consider carefully before enabling this as it can cause unexpected behavior,
|
|
168
|
-
and consider providing explicit keys to [`useState`](/docs/
|
|
168
|
+
and consider providing explicit keys to [`useState`](/docs/api/composables/use-state) as auto-generated keys may not match across builds.
|
|
169
169
|
::
|
|
170
170
|
|
|
171
171
|
```ts twoslash [nuxt.config.ts]
|
|
@@ -178,7 +178,7 @@ export default defineNuxtConfig({
|
|
|
178
178
|
|
|
179
179
|
## inlineRouteRules
|
|
180
180
|
|
|
181
|
-
Define route rules at the page level using [`defineRouteRules`](/docs/
|
|
181
|
+
Define route rules at the page level using [`defineRouteRules`](/docs/api/utils/define-route-rules).
|
|
182
182
|
|
|
183
183
|
```ts twoslash [nuxt.config.ts]
|
|
184
184
|
export default defineNuxtConfig({
|
|
@@ -190,11 +190,11 @@ export default defineNuxtConfig({
|
|
|
190
190
|
|
|
191
191
|
Matching route rules will be created, based on the page's `path`.
|
|
192
192
|
|
|
193
|
-
::read-more{to="/docs/
|
|
193
|
+
::read-more{to="/docs/api/utils/define-route-rules" icon="i-lucide-square-function"}
|
|
194
194
|
Read more in `defineRouteRules` utility.
|
|
195
195
|
::
|
|
196
196
|
|
|
197
|
-
:read-more{to="/docs/
|
|
197
|
+
:read-more{to="/docs/guide/concepts/rendering#hybrid-rendering" icon="i-lucide-medal"}
|
|
198
198
|
|
|
199
199
|
## renderJsonPayloads
|
|
200
200
|
|
|
@@ -254,7 +254,7 @@ export default defineNuxtConfig({
|
|
|
254
254
|
})
|
|
255
255
|
```
|
|
256
256
|
|
|
257
|
-
::read-more{to="/docs/
|
|
257
|
+
::read-more{to="/docs/getting-started/prerendering#payload-extraction"}
|
|
258
258
|
Read more about payload extraction and the consequences of each mode.
|
|
259
259
|
::
|
|
260
260
|
|
|
@@ -278,9 +278,52 @@ export default defineNuxtConfig({
|
|
|
278
278
|
})
|
|
279
279
|
```
|
|
280
280
|
|
|
281
|
+
## serverPathFallback
|
|
282
|
+
|
|
283
|
+
Loads a client-side navigation that matches no page route as a full document, so the server can respond with a file in `public/`, a server route, or its 404 page. With this enabled, `<NuxtLink to="/brochure.pdf">` and `<NuxtLink to="/rss.xml">` work on click as they do on a hard load.
|
|
284
|
+
|
|
285
|
+
A path is never reloaded if the current document was already served for it, so hosts that respond to unknown paths with an SPA fallback render the client-side 404 page.
|
|
286
|
+
|
|
287
|
+
This flag is enabled by default, but you can disable it:
|
|
288
|
+
|
|
289
|
+
```ts twoslash [nuxt.config.ts]
|
|
290
|
+
export default defineNuxtConfig({
|
|
291
|
+
experimental: {
|
|
292
|
+
serverPathFallback: false,
|
|
293
|
+
},
|
|
294
|
+
})
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
The option has no effect when `hashMode` is enabled.
|
|
298
|
+
|
|
299
|
+
## early404
|
|
300
|
+
|
|
301
|
+
Responds with an early 404 error for requests whose path cannot match any page route, without loading the Vue app, its plugins or middleware on the server.
|
|
302
|
+
|
|
303
|
+
Page routes (including aliases) are compiled into a static route matcher at build time, and incoming requests are checked against it before server-side rendering begins. Requests that cannot match any page skip loading the app entirely and go straight to the error page.
|
|
304
|
+
|
|
305
|
+
Requests without an `Accept: text/html` header (API clients, most scanners) receive a JSON error without loading the app at all, unless `future.compatibilityVersion` is `5`. HTML requests still server-render the error page. A [`cache` route rule](/docs/guide/concepts/rendering#hybrid-rendering) covering the path advertises its `maxAge` as `Cache-Control` on GET/HEAD misses too, letting a CDN absorb repeat requests for unknown paths.
|
|
306
|
+
|
|
307
|
+
```ts twoslash [nuxt.config.ts]
|
|
308
|
+
export default defineNuxtConfig({
|
|
309
|
+
experimental: {
|
|
310
|
+
early404: true,
|
|
311
|
+
},
|
|
312
|
+
})
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
::warning
|
|
316
|
+
This is opt-in because it can break apps that rely on runtime routing:
|
|
317
|
+
|
|
318
|
+
- pages added dynamically with `router.addRoute()` in a plugin. To surface this early, `addRoute` is removed from the type of the router returned by [`useRouter`](/docs/api/composables/use-router) when the option is enabled.
|
|
319
|
+
- route middleware that redirects unknown paths to existing pages
|
|
320
|
+
|
|
321
|
+
The option is disabled automatically in development, when `hashMode` is enabled, when a root-level catch-all page (such as `pages/[...slug].vue`) matches every path, and when a custom `app/router.options` file may modify `routes` (a file whose default export is a plain object without a `routes` key remains compatible).
|
|
322
|
+
::
|
|
323
|
+
|
|
281
324
|
## clientFallback
|
|
282
325
|
|
|
283
|
-
Enables the experimental [`<NuxtClientFallback>`](/docs/
|
|
326
|
+
Enables the experimental [`<NuxtClientFallback>`](/docs/api/components/nuxt-client-fallback) component for rendering content on the client if there's an error in SSR.
|
|
284
327
|
|
|
285
328
|
```ts twoslash [nuxt.config.ts]
|
|
286
329
|
export default defineNuxtConfig({
|
|
@@ -318,7 +361,7 @@ export default defineNuxtConfig({
|
|
|
318
361
|
})
|
|
319
362
|
```
|
|
320
363
|
|
|
321
|
-
You can also pass an object to configure [view transition types](/docs/
|
|
364
|
+
You can also pass an object to configure [view transition types](/docs/getting-started/transitions#view-transition-types), which allow different CSS animations based on the type of navigation:
|
|
322
365
|
|
|
323
366
|
```ts twoslash [nuxt.config.ts]
|
|
324
367
|
export default defineNuxtConfig({
|
|
@@ -354,7 +397,7 @@ export default defineNuxtConfig({
|
|
|
354
397
|
|
|
355
398
|
## componentIslands
|
|
356
399
|
|
|
357
|
-
Enables experimental component islands support with [`<NuxtIsland>`](/docs/
|
|
400
|
+
Enables experimental component islands support with [`<NuxtIsland>`](/docs/api/components/nuxt-island) and `.island.vue` files.
|
|
358
401
|
|
|
359
402
|
```ts twoslash [nuxt.config.ts]
|
|
360
403
|
export default defineNuxtConfig({
|
|
@@ -364,10 +407,10 @@ export default defineNuxtConfig({
|
|
|
364
407
|
})
|
|
365
408
|
```
|
|
366
409
|
|
|
367
|
-
:read-more{to="/docs/
|
|
410
|
+
:read-more{to="/docs/guide/concepts/server-components"}
|
|
368
411
|
|
|
369
412
|
::note
|
|
370
|
-
Skip `nuxt-client` on non-SFC components such as [`<NuxtLink>`](/docs/
|
|
413
|
+
Skip `nuxt-client` on non-SFC components such as [`<NuxtLink>`](/docs/api/components/nuxt-link). See [selective hydration with `nuxt-client`](/docs/guide/concepts/server-components#selective-hydration-with-nuxt-client).
|
|
371
414
|
::
|
|
372
415
|
|
|
373
416
|
::read-more{icon="i-simple-icons-github" to="https://github.com/nuxt/nuxt/issues/19772" target="_blank"}
|
|
@@ -400,7 +443,7 @@ export default defineNuxtConfig({
|
|
|
400
443
|
})
|
|
401
444
|
```
|
|
402
445
|
|
|
403
|
-
Out of the box, this will enable typed usage of [`navigateTo`](/docs/
|
|
446
|
+
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.
|
|
404
447
|
|
|
405
448
|
You can even get typed params within a page by using `const route = useRoute('route-name')`.
|
|
406
449
|
|
|
@@ -594,7 +637,36 @@ export default defineNuxtConfig({
|
|
|
594
637
|
})
|
|
595
638
|
```
|
|
596
639
|
|
|
597
|
-
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/
|
|
640
|
+
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/directory-structure/app/pages#typing-custom-metadata).
|
|
641
|
+
|
|
642
|
+
## extractSerializablePageMeta
|
|
643
|
+
|
|
644
|
+
Enabled by default when `future.compatibilityVersion` is `5` or higher.
|
|
645
|
+
|
|
646
|
+
By default, Nuxt only reads a fixed list of `definePageMeta()` keys at build time (plus anything in `extraPageMetaExtractionKeys`); everything else is resolved at runtime from a separate module generated per page. With this option, Nuxt writes every JSON-serializable property straight into the generated route record instead.
|
|
647
|
+
|
|
648
|
+
When every property of a page's `definePageMeta()` can be resolved statically, the route no longer imports that page's meta module at all, which removes one module per page from the dev module graph.
|
|
649
|
+
|
|
650
|
+
```vue
|
|
651
|
+
<script lang="ts" setup>
|
|
652
|
+
definePageMeta({
|
|
653
|
+
layout: { name: 'admin', props: { collapsed: true } },
|
|
654
|
+
title: 'Dashboard',
|
|
655
|
+
})
|
|
656
|
+
</script>
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
Properties whose values cannot be serialized (functions, variable references, spreads, computed keys) are unaffected and still resolved at runtime.
|
|
660
|
+
|
|
661
|
+
This has no effect when [`scanPageMeta`](#scanpagemeta) is `false`, as the route record does not override the meta module in that case.
|
|
662
|
+
|
|
663
|
+
```ts twoslash [nuxt.config.ts]
|
|
664
|
+
export default defineNuxtConfig({
|
|
665
|
+
experimental: {
|
|
666
|
+
extractSerializablePageMeta: false,
|
|
667
|
+
},
|
|
668
|
+
})
|
|
669
|
+
```
|
|
598
670
|
|
|
599
671
|
## navigationRepaint
|
|
600
672
|
|
|
@@ -612,6 +684,43 @@ export default defineNuxtConfig({
|
|
|
612
684
|
})
|
|
613
685
|
```
|
|
614
686
|
|
|
687
|
+
## navigateToEarlyReturn
|
|
688
|
+
|
|
689
|
+
Transform top-level `await navigateTo()` calls in `<script setup>` into an early return from the compiled `setup()` function when the navigation succeeds.
|
|
690
|
+
|
|
691
|
+
Without this flag, code after `await navigateTo()` continues to run, which can result in later code (including subsequent `navigateTo` calls) overriding the redirect or attempting to render a page with missing data. With this flag enabled, a successful navigation stops execution of the rest of your setup code and the component renders a placeholder comment while the navigation proceeds.
|
|
692
|
+
|
|
693
|
+
This flag is enabled by default with `compatibilityVersion: 5`, but you can disable it:
|
|
694
|
+
|
|
695
|
+
```ts twoslash [nuxt.config.ts]
|
|
696
|
+
export default defineNuxtConfig({
|
|
697
|
+
experimental: {
|
|
698
|
+
navigateToEarlyReturn: false,
|
|
699
|
+
},
|
|
700
|
+
})
|
|
701
|
+
```
|
|
702
|
+
|
|
703
|
+
```vue [pages/example.vue]
|
|
704
|
+
<script setup lang="ts">
|
|
705
|
+
const { data } = await useFetch('/api/data')
|
|
706
|
+
|
|
707
|
+
if (!data.value) {
|
|
708
|
+
await navigateTo('/fallback')
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
// with the flag enabled, this only runs if the navigation did not happen
|
|
712
|
+
const processed = data.value!.map(item => item.name)
|
|
713
|
+
</script>
|
|
714
|
+
```
|
|
715
|
+
|
|
716
|
+
The transform only applies to top-level `await navigateTo()` statements in `<script setup>` whose result is not used. Calls with the `open` option (or options that cannot be statically analysed) are not transformed, as they should not stop the current page from rendering.
|
|
717
|
+
|
|
718
|
+
The early return only happens when the navigation succeeds (that is, when `navigateTo` resolves to `undefined`). If the navigation is aborted or fails (for example, blocked by a navigation guard, or navigating to the current route), the rest of your setup code continues to run. On a successful navigation, nothing after the `navigateTo` call runs: this includes `defineExpose` and any lifecycle hook registrations later in `<script setup>`.
|
|
719
|
+
|
|
720
|
+
::read-more{icon="i-simple-icons-github" to="https://github.com/nuxt/nuxt/issues/23698" target="_blank"}
|
|
721
|
+
See full explanation on the GitHub issue.
|
|
722
|
+
::
|
|
723
|
+
|
|
615
724
|
## normalizeComponentNames
|
|
616
725
|
|
|
617
726
|
Nuxt updates auto-generated Vue component names to match the full component name you would use to auto-import the component.
|
|
@@ -742,7 +851,7 @@ export default defineNuxtConfig({
|
|
|
742
851
|
})
|
|
743
852
|
```
|
|
744
853
|
|
|
745
|
-
::read-more{icon="i-simple-icons-github" color="gray" to="/docs/
|
|
854
|
+
::read-more{icon="i-simple-icons-github" color="gray" to="/docs/directory-structure/app/components#delayed-or-lazy-hydration"}
|
|
746
855
|
Read more about lazy hydration.
|
|
747
856
|
::
|
|
748
857
|
|
|
@@ -868,7 +977,7 @@ export default defineNuxtConfig({
|
|
|
868
977
|
})
|
|
869
978
|
```
|
|
870
979
|
|
|
871
|
-
The `useState.resetOnClear` option controls whether [`clearNuxtState`](/docs/
|
|
980
|
+
The `useState.resetOnClear` option controls whether [`clearNuxtState`](/docs/api/utils/clear-nuxt-state) resets state to its initial value (provided by the `init` function of [`useState`](/docs/api/composables/use-state)) instead of setting it to `undefined`. This defaults to `true` with `compatibilityVersion: 5`.
|
|
872
981
|
|
|
873
982
|
## purgeCachedData
|
|
874
983
|
|
|
@@ -892,12 +1001,16 @@ See PR #31379 for implementation details.
|
|
|
892
1001
|
|
|
893
1002
|
## prefetchPreloadTags
|
|
894
1003
|
|
|
895
|
-
When a `<NuxtLink>` is prefetched and the destination route has [payload extraction](#payloadextraction) enabled (the default for prerendered and cached routes), forward any `<link rel="preload">` hints that the destination set via [`useHead`](/docs/
|
|
1004
|
+
When a `<NuxtLink>` is prefetched and the destination route has [payload extraction](#payloadextraction) enabled (the default for prerendered and cached routes), forward any `<link rel="preload">` hints that the destination set via [`useHead`](/docs/api/composables/use-head) (or via modules like [`@nuxt/image`](https://image.nuxt.com)'s `<NuxtImg preload>`) into the current document.
|
|
1005
|
+
|
|
1006
|
+
Forwarded links are downgraded from `rel="preload"` to `rel="prefetch"`, apart from `as="image"` hints, which keep `rel="preload"` with any `fetchpriority` stripped.
|
|
896
1007
|
|
|
897
|
-
|
|
1008
|
+
Only user-defined head tags are forwarded; build-time JS/CSS chunk preloads are already handled separately by the prefetch pipeline.
|
|
898
1009
|
|
|
899
1010
|
This flag is off by default because, combined with `prefetchOn: 'visibility'` (the `<NuxtLink>` default), it could trigger a lot of cross-route prefetches at once. Enable it once you are confident the destination preloads are worth forwarding for the links your users typically encounter.
|
|
900
1011
|
|
|
1012
|
+
Chromium and Safari log a `was preloaded using link preload but not used within a few seconds` warning for each forwarded image hint on a route the user never visits. Forwarded image requests also carry no `Purpose: prefetch` header, so they count as ordinary traffic against image CDN quotas, rate limits and analytics.
|
|
1013
|
+
|
|
901
1014
|
```ts twoslash [nuxt.config.ts]
|
|
902
1015
|
export default defineNuxtConfig({
|
|
903
1016
|
experimental: {
|
|
@@ -928,6 +1041,20 @@ export default defineNuxtConfig({
|
|
|
928
1041
|
See PR #31373 for implementation details.
|
|
929
1042
|
::
|
|
930
1043
|
|
|
1044
|
+
## stripNeverHydratedData
|
|
1045
|
+
|
|
1046
|
+
Apply [`serialize: false`](/docs/api/composables/use-async-data#params) by default to `useAsyncData` and `useFetch` calls made within components lazily hydrated with `hydrate-never`, keeping their data out of the `__NUXT_DATA__` payload. Since these components never hydrate on the client, their data is not needed for hydration.
|
|
1047
|
+
|
|
1048
|
+
```ts twoslash [nuxt.config.ts]
|
|
1049
|
+
export default defineNuxtConfig({
|
|
1050
|
+
experimental: {
|
|
1051
|
+
stripNeverHydratedData: true,
|
|
1052
|
+
},
|
|
1053
|
+
})
|
|
1054
|
+
```
|
|
1055
|
+
|
|
1056
|
+
An explicit `serialize` option always takes precedence. If the same key is shared with components that do hydrate, keep the `serialize` option consistent across calls (Nuxt warns about mismatches in development).
|
|
1057
|
+
|
|
931
1058
|
## headNext
|
|
932
1059
|
|
|
933
1060
|
Use head optimisations:
|
|
@@ -945,6 +1072,103 @@ export default defineNuxtConfig({
|
|
|
945
1072
|
})
|
|
946
1073
|
```
|
|
947
1074
|
|
|
1075
|
+
## routeTypedFetch
|
|
1076
|
+
|
|
1077
|
+
Type `$fetch` and `useFetch` from the routes your server builder reports, rather than from the
|
|
1078
|
+
responses nitro contributes to `ServerRoutes` through its `InternalApi` interface.
|
|
1079
|
+
|
|
1080
|
+
```ts twoslash [nuxt.config.ts]
|
|
1081
|
+
export default defineNuxtConfig({
|
|
1082
|
+
experimental: {
|
|
1083
|
+
routeTypedFetch: true,
|
|
1084
|
+
},
|
|
1085
|
+
})
|
|
1086
|
+
```
|
|
1087
|
+
|
|
1088
|
+
The generated route set carries the `body`, `query` and `headers` a handler validates as well as its
|
|
1089
|
+
response, typed as it arrives over the wire, so a resolving call is typed more tightly than before:
|
|
1090
|
+
|
|
1091
|
+
- a `Date` a handler returns is a `string` at the call site
|
|
1092
|
+
- a `body` the handler validates cannot be omitted or given the wrong shape
|
|
1093
|
+
- a method the route does not answer is rejected
|
|
1094
|
+
- `params` is no longer accepted, since it was only ever an alias for `query`
|
|
1095
|
+
- a route you registered by augmenting `ServerRoutes` by hand needs rewriting, as the two
|
|
1096
|
+
descriptions of a route differ (see [the upgrade guide](https://nuxt.com/docs/5.x/getting-started/upgrade#typed-fetch-rebuilt-on-generated-route-types)).
|
|
1097
|
+
A route declared with `Endpoint` (imported from `nuxt/app`) in the rewritten shape is typed
|
|
1098
|
+
with `routeTypedFetch` both on and off, so you can rewrite it ahead of the switch
|
|
1099
|
+
|
|
1100
|
+
Because of those, it is opt-in, and `future.compatibilityVersion: 5` enables it. Setting it
|
|
1101
|
+
explicitly selects either typing whatever the compatibility version, so you can adopt it before
|
|
1102
|
+
moving to Nuxt 5, or move to Nuxt 5 with `routeTypedFetch: false` and adopt it separately.
|
|
1103
|
+
|
|
1104
|
+
::note
|
|
1105
|
+
This option exists only while both typings are supported. From Nuxt 5 the generated route set is the
|
|
1106
|
+
only source and the option is gone.
|
|
1107
|
+
::
|
|
1108
|
+
|
|
1109
|
+
::note
|
|
1110
|
+
While Nuxt 4 runs on nitro v2, nitro declares a global `$fetch` of its own, typed from
|
|
1111
|
+
`InternalApi`. Import `$fetch` from `#build/fetch` where you want the generated route types to apply
|
|
1112
|
+
to a direct call; `useFetch`, `useLazyFetch` and `useRequestFetch()` are unaffected.
|
|
1113
|
+
::
|
|
1114
|
+
|
|
1115
|
+
## strictRouteTypes
|
|
1116
|
+
|
|
1117
|
+
Reject a request to a path no server route answers. Requires
|
|
1118
|
+
[`routeTypedFetch`](#routetypedfetch), which types `$fetch` and `useFetch` from the routes your
|
|
1119
|
+
server will serve.
|
|
1120
|
+
|
|
1121
|
+
```ts twoslash [nuxt.config.ts]
|
|
1122
|
+
export default defineNuxtConfig({
|
|
1123
|
+
experimental: {
|
|
1124
|
+
routeTypedFetch: true,
|
|
1125
|
+
strictRouteTypes: true,
|
|
1126
|
+
},
|
|
1127
|
+
})
|
|
1128
|
+
```
|
|
1129
|
+
|
|
1130
|
+
With `routeTypedFetch` enabled a response is typed by the handler that answers it whatever this
|
|
1131
|
+
option is set to. What the option decides is whether a path Nuxt does not recognise is an error or
|
|
1132
|
+
is simply typed as `unknown`.
|
|
1133
|
+
|
|
1134
|
+
- `false` (default) - a path Nuxt does not recognise is accepted and resolves to `unknown`, and no
|
|
1135
|
+
method is rejected. Nuxt cannot see every way a request may be answered: nitro middleware, a
|
|
1136
|
+
[`routeRules`](/docs/guide/concepts/rendering#hybrid-rendering) proxy or a catch-all handler
|
|
1137
|
+
can answer a path no route describes.
|
|
1138
|
+
- `true` - only the routes your server builder reports are accepted, for the methods they answer.
|
|
1139
|
+
- `'isomorphic'` - as `true`, and your pages are included as `GET` routes returning `string`, so
|
|
1140
|
+
`$fetch('/about')` is typed by the route the Vue router serves rather than rejected.
|
|
1141
|
+
|
|
1142
|
+
With the option on, a typo and a method the route does not answer are both errors:
|
|
1143
|
+
|
|
1144
|
+
```ts
|
|
1145
|
+
// server/api/todos.post.ts answers POST only
|
|
1146
|
+
await $fetch('/api/todos', { method: 'POST' })
|
|
1147
|
+
await $fetch('/api/todo', { method: 'POST' })
|
|
1148
|
+
// ^ no POST route matches '/api/todo'
|
|
1149
|
+
await $fetch('/api/todos')
|
|
1150
|
+
// ^ no GET route matches '/api/todos'
|
|
1151
|
+
```
|
|
1152
|
+
|
|
1153
|
+
Two things stay accepted, because they are not Nuxt's to describe: an absolute URL
|
|
1154
|
+
(`$fetch('https://example.com')`), and a path built at runtime, which resolves to `unknown` as it
|
|
1155
|
+
does with the option off. A `baseURL` is resolved into the path before it is matched, so a request
|
|
1156
|
+
made through one is checked against the route it actually asks for. Naming the response type also
|
|
1157
|
+
opts a call out, since doing so turns off inference for the request:
|
|
1158
|
+
|
|
1159
|
+
```ts
|
|
1160
|
+
const data = await $fetch<{ id: string }>(`/api/${resource}`)
|
|
1161
|
+
```
|
|
1162
|
+
|
|
1163
|
+
::note
|
|
1164
|
+
Files in your `public/` directory are not routes your server builder reports, so requesting one
|
|
1165
|
+
with `strictRouteTypes` enabled is an error. Fetch those with an explicit response type, or leave
|
|
1166
|
+
the option off.
|
|
1167
|
+
::
|
|
1168
|
+
|
|
1169
|
+
Set this only where your routing is enumerable. An app with a catch-all page under `'isomorphic'`
|
|
1170
|
+
matches every path, which is correct but means the option constrains nothing.
|
|
1171
|
+
|
|
948
1172
|
## pendingWhenIdle
|
|
949
1173
|
|
|
950
1174
|
`pendingWhenIdle` controls the `pending` ref returned by `useAsyncData` and `useFetch`.
|
|
@@ -1037,7 +1261,7 @@ export default defineNuxtConfig({
|
|
|
1037
1261
|
The Vite Environment API provides better consistency between development and production builds, more granular control over environment-specific configuration, and improved performance.
|
|
1038
1262
|
|
|
1039
1263
|
::important
|
|
1040
|
-
Enabling this feature changes how Vite plugins are registered and configured. See the [Vite Environment API migration guide](/docs/
|
|
1264
|
+
Enabling this feature changes how Vite plugins are registered and configured. See the [Vite Environment API migration guide](https://nuxt.com/docs/5.x/getting-started/upgrade#migration-to-vite-environment-api) for details on updating your plugins.
|
|
1041
1265
|
::
|
|
1042
1266
|
|
|
1043
1267
|
::read-more{to="https://vite.dev/guide/api-environment" target="_blank"}
|
|
@@ -1056,7 +1280,9 @@ export default defineNuxtConfig({
|
|
|
1056
1280
|
})
|
|
1057
1281
|
```
|
|
1058
1282
|
|
|
1059
|
-
Streaming is automatically disabled for bot and crawler user agents (such as Googlebot, Bingbot, etc.) to ensure search engines receive fully-rendered HTML for SEO safety. The default pattern matches indexing crawlers only; Lighthouse and other audit tools deliberately fall outside it so synthetic measurements reflect the same streamed response real users get.
|
|
1283
|
+
Streaming is automatically disabled for bot and crawler user agents (such as Googlebot, Bingbot, etc.) to ensure search engines receive fully-rendered HTML for SEO safety. The default pattern matches indexing crawlers only; Lighthouse and other audit tools deliberately fall outside it so synthetic measurements reflect the same streamed response real users get.
|
|
1284
|
+
|
|
1285
|
+
You can customise which user agents are opted out with `botRegex`. A request whose `user-agent` header matches the pattern is **not** streamed: it receives the fully-rendered, buffered HTML. Requests that do not match are streamed. Setting `botRegex` replaces the default pattern rather than adding to it, so list every crawler you want to keep out of streaming:
|
|
1060
1286
|
|
|
1061
1287
|
```ts twoslash [nuxt.config.ts]
|
|
1062
1288
|
export default defineNuxtConfig({
|
|
@@ -1086,7 +1312,7 @@ export default defineNuxtConfig({
|
|
|
1086
1312
|
|
|
1087
1313
|
- `routeRules` setting `noScripts`, `cache`, `isr`, `swr`, `redirect`, or `streaming: false` for the route
|
|
1088
1314
|
- `ssr: false` routes (already SPA-rendered)
|
|
1089
|
-
- Bot/crawler user agents
|
|
1315
|
+
- Bot/crawler user agents, that is, requests whose `user-agent` matches `botRegex`
|
|
1090
1316
|
- Prerendered routes (`nuxt generate`)
|
|
1091
1317
|
- Server-side `navigateTo()` redirects from plugins, middleware, or page setup
|
|
1092
1318
|
- Fatal errors thrown during initial render (before the shell flushes)
|
|
@@ -1116,6 +1342,12 @@ If an error occurs during streaming after the HTTP status is already committed,
|
|
|
1116
1342
|
**Route styles are streamed, JS hints are entry-only.** The shell is flushed before the route renders, so its `<head>` carries entry-chunk styles and hints only. Once render registers the page and layout modules, their CSS is streamed straight after the shell (inlined as `<style>` when `inlineStyles` is enabled, otherwise as stylesheet links), so page, layout, and top-level async-component styles arrive before the body paints (nested async components are a FOUC caveat, covered below). Route-specific JS chunks are not preloaded from the shell; the browser discovers them after parsing the entry script. Streaming improves TTFB on every route; LCP gains are largest on routes whose JS overlaps the entry chunk.
|
|
1117
1343
|
::
|
|
1118
1344
|
|
|
1345
|
+
::warning
|
|
1346
|
+
**Head tags registered after the shell flushes become client-side patches.** The renderer waits for the first render pass before flushing the shell, so `useHead`/`useSeoMeta` called synchronously in `<script setup>` (before any `await`), in plugins, or in middleware render into the shell `<head>` as usual. Tags registered later (after an `await` in setup, or inside a nested `<Suspense>` boundary) cannot reach the already-sent `<head>`; they are delivered as inline scripts that patch the DOM on the client.
|
|
1347
|
+
|
|
1348
|
+
Clients that run JavaScript apply the patch, and clients matching `botRegex` never stream in the first place, so they receive the full buffered `<head>`. Anything else (a crawler your `botRegex` does not list, a link unfurler, `curl`) will not see those tags at all. JSON-LD scripts, `noscript` tags and body-positioned tags are the exception: they are rendered as real markup before `</body>`, where every client can read them. Keep other SEO-critical tags (canonical links, social meta) synchronous, or opt the route out of streaming with `routeRules: { '/path': { streaming: false } }`.
|
|
1349
|
+
::
|
|
1350
|
+
|
|
1119
1351
|
::note
|
|
1120
1352
|
**Component islands are compatible with streaming.** Island slot content and selective-client (`nuxt-client`) components are normally stitched into the HTML in a post-render pass, which is impossible once the body has streamed past the island anchors. Instead, the renderer emits each island teleport as an inert `<template>` at the end of the document and relocates it into place with an inline script that runs before hydration. This is transparent to app code. The exception is apps built with `features.noScripts` and island components, which fall back to the buffered renderer since the relocation script cannot run.
|
|
1121
1353
|
::
|
|
@@ -41,20 +41,56 @@ export default defineNuxtConfig({
|
|
|
41
41
|
|
|
42
42
|
### noScripts
|
|
43
43
|
|
|
44
|
-
Turn off rendering of Nuxt scripts and JavaScript resource hints
|
|
44
|
+
Turn off rendering of Nuxt scripts and JavaScript resource hints, so pages ship as pure HTML and CSS.
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
Possible values:
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
- `false` (default): scripts are rendered normally.
|
|
49
|
+
- `'production'` (or `true`, which is normalized to `'production'`): scripts are omitted in production builds only, so hot module replacement and other development features keep working in `nuxt dev`.
|
|
50
|
+
- `'all'`: scripts are omitted in both development and production.
|
|
51
|
+
|
|
52
|
+
Pages served without scripts navigate with full-page loads. To keep navigation fast, Nuxt emits a [speculation rules](https://developer.mozilla.org/en-US/docs/Web/API/Speculation_Rules_API) tag on these pages so supporting browsers prefetch and prerender the targets before the user follows a link. The tag is declarative JSON and executes no JavaScript. The rules are scoped to your page routes (which are safe to `GET`) rather than every same-origin link, so a link to a server route such as `/logout` is never speculatively fetched. A catch-all page (for example `pages/[...slug].vue`) matches every path, which widens this back to all same-origin links.
|
|
53
|
+
|
|
54
|
+
Client-side navigation *to* a route covered by a `noScripts` route rule triggers a full document load instead, so the route is actually served without scripts rather than being rendered by the client-side router. Pages whose routes are known at build time to be covered by such a rule are also excluded from the client bundle entirely.
|
|
55
|
+
|
|
56
|
+
Scripted pages emit their own speculation rules tag scoped to the `noScripts` route patterns, so browsers can prefetch and prerender those targets before a full-page navigation to them. When view transitions are enabled, these pages also opt into declarative cross-document view transitions to animate the navigation.
|
|
49
57
|
|
|
50
58
|
```ts [nuxt.config.ts]
|
|
51
59
|
export default defineNuxtConfig({
|
|
52
60
|
features: {
|
|
53
|
-
noScripts:
|
|
61
|
+
noScripts: 'production', // or 'all' | false
|
|
54
62
|
},
|
|
55
63
|
})
|
|
56
64
|
```
|
|
57
65
|
|
|
66
|
+
You can also disable scripts per-route with the `noScripts` [route rule](/docs/guide/concepts/rendering#hybrid-rendering), which applies in all modes:
|
|
67
|
+
|
|
68
|
+
```ts [nuxt.config.ts]
|
|
69
|
+
export default defineNuxtConfig({
|
|
70
|
+
routeRules: {
|
|
71
|
+
'/blog/**': { noScripts: true },
|
|
72
|
+
},
|
|
73
|
+
})
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
When `noScripts` applies to a rendered page, the following are omitted from the HTML:
|
|
77
|
+
|
|
78
|
+
- the Nuxt entry `<script>` tags
|
|
79
|
+
- the import map for the entry chunk
|
|
80
|
+
- the inlined payload `<script>` (and the payload preload link, when payload extraction is enabled)
|
|
81
|
+
- JavaScript resource hints (`preload` and `prefetch` links for JS chunks)
|
|
82
|
+
|
|
83
|
+
CSS is unaffected: stylesheet links and inlined styles are still rendered, so the page looks identical. The page simply never hydrates, which means nothing on it is interactive.
|
|
84
|
+
|
|
85
|
+
A few interactions to be aware of:
|
|
86
|
+
|
|
87
|
+
- Routes with the `noScripts` route rule are always rendered with the buffered (non-streaming) renderer.
|
|
88
|
+
- [Server components](/docs/guide/concepts/server-components) that only render static HTML work fine, but components hydrated with `nuxt-client` and interactive island slots rely on an inline script to relocate teleported content, so they will not become interactive on a `noScripts` route. When `features.noScripts` is set app-wide and component islands are active, Nuxt also falls back to buffered rendering for this reason.
|
|
89
|
+
|
|
90
|
+
::read-more{to="/docs/guide/recipes/mostly-static-sites"}
|
|
91
|
+
See the mostly-static site recipe for combining `noScripts` with prerendering, islands and lazy hydration.
|
|
92
|
+
::
|
|
93
|
+
|
|
58
94
|
## `future`
|
|
59
95
|
|
|
60
96
|
There is also a `future` namespace for early opting-in to new features that will become default in a future (possibly major) version of the framework.
|
|
@@ -63,7 +99,7 @@ There is also a `future` namespace for early opting-in to new features that will
|
|
|
63
99
|
|
|
64
100
|
This enables early access to Nuxt features or flags.
|
|
65
101
|
|
|
66
|
-
Setting `compatibilityVersion` to `5` changes defaults throughout your Nuxt configuration to opt in to Nuxt v5 behaviour, including enabling the [Vite Environment API](/docs/
|
|
102
|
+
Setting `compatibilityVersion` to `5` changes defaults throughout your Nuxt configuration to opt in to Nuxt v5 behaviour, including enabling the [Vite Environment API](/docs/guide/going-further/experimental-features#viteenvironmentapi).
|
|
67
103
|
|
|
68
104
|
```ts
|
|
69
105
|
export default defineNuxtConfig({
|
|
@@ -73,7 +109,7 @@ export default defineNuxtConfig({
|
|
|
73
109
|
})
|
|
74
110
|
```
|
|
75
111
|
|
|
76
|
-
::read-more{to="/docs/
|
|
112
|
+
::read-more{to="/docs/getting-started/upgrade#testing-nuxt-5"}
|
|
77
113
|
Learn more about testing Nuxt 5.
|
|
78
114
|
::
|
|
79
115
|
|
|
@@ -8,15 +8,15 @@ This guide helps you better understand Nuxt internals to develop new solutions a
|
|
|
8
8
|
|
|
9
9
|
## The Nuxt Interface
|
|
10
10
|
|
|
11
|
-
When you start Nuxt in development mode with [`nuxt dev`](/docs/
|
|
11
|
+
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),
|
|
12
12
|
a common context will be created, referred to as `nuxt` internally. It holds normalized options merged with `nuxt.config` file,
|
|
13
|
-
some internal state, and a powerful [hooking system](/docs/
|
|
13
|
+
some internal state, and a powerful [hooking system](/docs/api/advanced/hooks) powered by [unjs/hookable](https://github.com/unjs/hookable)
|
|
14
14
|
allowing different components to communicate with each other. You can think of it as **Builder Core**.
|
|
15
15
|
|
|
16
|
-
This context is globally available to be used with [Nuxt Kit](/docs/
|
|
16
|
+
This context is globally available to be used with [Nuxt Kit](/docs/guide/going-further/kit) composables.
|
|
17
17
|
Therefore only one instance of Nuxt is allowed to run per process.
|
|
18
18
|
|
|
19
|
-
To extend the Nuxt interface and hook into different stages of the build process, we can use [Nuxt modules](/docs/
|
|
19
|
+
To extend the Nuxt interface and hook into different stages of the build process, we can use [Nuxt modules](/docs/guide/modules).
|
|
20
20
|
|
|
21
21
|
For more details, check out [the source code](https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/core/nuxt.ts).
|
|
22
22
|
|
|
@@ -26,14 +26,14 @@ When rendering a page in the browser or on the server, a shared context will be
|
|
|
26
26
|
This context keeps vue instance, runtime hooks, and internal states like ssrContext and payload for hydration.
|
|
27
27
|
You can think of it as **Runtime Core**.
|
|
28
28
|
|
|
29
|
-
This context can be accessed using [`useNuxtApp()`](/docs/
|
|
29
|
+
This context can be accessed using [`useNuxtApp()`](/docs/api/composables/use-nuxt-app) composable within Nuxt plugins and `<script setup>` and vue composables.
|
|
30
30
|
Global usage is possible for the browser but not on the server, to avoid sharing context between users.
|
|
31
31
|
|
|
32
|
-
Since [`useNuxtApp`](/docs/
|
|
32
|
+
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.
|
|
33
33
|
|
|
34
|
-
To extend the `nuxtApp` interface and hook into different stages or access contexts, we can use [Nuxt Plugins](/docs/
|
|
34
|
+
To extend the `nuxtApp` interface and hook into different stages or access contexts, we can use [Nuxt Plugins](/docs/directory-structure/app/plugins).
|
|
35
35
|
|
|
36
|
-
Check [Nuxt App](/docs/
|
|
36
|
+
Check [Nuxt App](/docs/api/composables/use-nuxt-app) for more information about this interface.
|
|
37
37
|
|
|
38
38
|
`nuxtApp` has the following properties:
|
|
39
39
|
|
|
@@ -77,6 +77,6 @@ Nuxt builds and bundles project using Node.js but also has a runtime side.
|
|
|
77
77
|
|
|
78
78
|
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!
|
|
79
79
|
|
|
80
|
-
`nuxt.config` and [Nuxt modules](/docs/
|
|
80
|
+
`nuxt.config` and [Nuxt modules](/docs/guide/modules) can be used to extend the build context, and [Nuxt Plugins](/docs/directory-structure/app/plugins) can be used to extend runtime.
|
|
81
81
|
|
|
82
|
-
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/
|
|
82
|
+
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/modules).
|