@nuxt/docs 3.20.1 → 3.21.0
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 +5 -5
- package/1.getting-started/02.installation.md +4 -7
- package/1.getting-started/03.configuration.md +32 -32
- package/1.getting-started/04.views.md +10 -8
- package/1.getting-started/05.assets.md +8 -8
- package/1.getting-started/06.styling.md +24 -18
- package/1.getting-started/07.routing.md +11 -11
- package/1.getting-started/08.seo-meta.md +10 -6
- package/1.getting-started/09.transitions.md +12 -12
- package/1.getting-started/10.data-fetching.md +18 -18
- package/1.getting-started/11.state-management.md +7 -7
- package/1.getting-started/12.error-handling.md +28 -22
- package/1.getting-started/13.server.md +9 -9
- package/1.getting-started/14.layers.md +52 -18
- package/1.getting-started/15.prerendering.md +10 -4
- package/1.getting-started/16.deployment.md +3 -2
- package/1.getting-started/17.testing.md +18 -8
- package/1.getting-started/18.upgrade.md +111 -60
- package/{2.guide/1.directory-structure → 2.directory-structure}/0.nuxt.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/0.output.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.assets.md +3 -3
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.components.md +13 -9
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.composables.md +4 -4
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.content.md +2 -2
- package/2.directory-structure/1.layers.md +87 -0
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.layouts.md +37 -5
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.middleware.md +8 -8
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.modules.md +10 -4
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.node_modules.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.pages.md +43 -22
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.plugins.md +6 -3
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.public.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.server.md +29 -9
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.shared.md +4 -4
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.utils.md +5 -5
- package/{2.guide/1.directory-structure → 2.directory-structure}/2.env.md +4 -4
- package/{2.guide/1.directory-structure → 2.directory-structure}/2.nuxtignore.md +2 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/2.nuxtrc.md +6 -3
- package/{2.guide/1.directory-structure → 2.directory-structure}/3.app-config.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/3.app.md +5 -5
- package/{2.guide/1.directory-structure → 2.directory-structure}/3.error.md +10 -8
- package/{2.guide/1.directory-structure → 2.directory-structure}/3.nuxt-config.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/3.package.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/3.tsconfig.md +3 -2
- package/2.directory-structure/index.md +65 -0
- package/3.guide/0.index.md +28 -0
- package/{2.guide/2.concepts/3.rendering.md → 3.guide/1.concepts/1.rendering.md} +8 -33
- package/{2.guide/2.concepts/2.vuejs-development.md → 3.guide/1.concepts/10.vuejs-development.md} +11 -10
- package/{2.guide/2.concepts/10.nuxt-lifecycle.md → 3.guide/1.concepts/2.nuxt-lifecycle.md} +34 -27
- package/{2.guide/2.concepts/1.auto-imports.md → 3.guide/1.concepts/3.auto-imports.md} +10 -10
- package/{2.guide/2.concepts → 3.guide/1.concepts}/4.server-engine.md +3 -3
- package/{2.guide/2.concepts → 3.guide/1.concepts}/5.modules.md +15 -2
- package/{2.guide/2.concepts → 3.guide/1.concepts}/7.esm.md +5 -4
- package/{2.guide/2.concepts → 3.guide/1.concepts}/8.typescript.md +11 -17
- package/{2.guide/2.concepts → 3.guide/1.concepts}/9.code-style.md +1 -1
- package/{2.guide/5.best-practices → 3.guide/2.best-practices}/hydration.md +1 -1
- package/{2.guide/5.best-practices → 3.guide/2.best-practices}/performance.md +5 -5
- package/3.guide/3.ai/.navigation.yml +3 -0
- package/3.guide/3.ai/1.mcp.md +277 -0
- package/3.guide/3.ai/2.llms-txt.md +65 -0
- package/3.guide/4.modules/.navigation.yml +3 -0
- package/3.guide/4.modules/1.getting-started.md +103 -0
- package/3.guide/4.modules/2.module-anatomy.md +138 -0
- package/3.guide/4.modules/3.recipes-basics.md +330 -0
- package/3.guide/4.modules/4.recipes-advanced.md +243 -0
- package/3.guide/4.modules/5.testing.md +76 -0
- package/3.guide/4.modules/6.best-practices.md +104 -0
- package/3.guide/4.modules/7.ecosystem.md +32 -0
- package/3.guide/4.modules/index.md +36 -0
- package/{2.guide/4.recipes → 3.guide/5.recipes}/1.custom-routing.md +4 -4
- package/{2.guide/4.recipes → 3.guide/5.recipes}/2.vite-plugin.md +5 -1
- package/{2.guide/4.recipes → 3.guide/5.recipes}/3.custom-usefetch.md +3 -3
- package/{2.guide/4.recipes → 3.guide/5.recipes}/4.sessions-and-authentication.md +2 -2
- package/{2.guide/3.going-further → 3.guide/6.going-further}/1.events.md +3 -4
- package/{2.guide/3.going-further → 3.guide/6.going-further}/1.experimental-features.md +212 -87
- package/3.guide/6.going-further/1.features.md +108 -0
- package/{2.guide/3.going-further → 3.guide/6.going-further}/1.internals.md +5 -4
- package/{2.guide/3.going-further → 3.guide/6.going-further}/10.runtime-config.md +3 -3
- package/{2.guide/3.going-further → 3.guide/6.going-further}/11.nightly-release-channel.md +1 -1
- package/{2.guide/3.going-further → 3.guide/6.going-further}/2.hooks.md +7 -7
- package/{2.guide/3.going-further → 3.guide/6.going-further}/4.kit.md +3 -3
- package/{2.guide/3.going-further → 3.guide/6.going-further}/6.nuxt-app.md +6 -6
- package/{2.guide/3.going-further → 3.guide/6.going-further}/7.layers.md +40 -14
- package/{2.guide/3.going-further → 3.guide/6.going-further}/9.debugging.md +3 -2
- package/{3.api → 4.api}/1.components/1.nuxt-client-fallback.md +5 -1
- package/{3.api → 4.api}/1.components/10.nuxt-picture.md +1 -1
- package/{3.api → 4.api}/1.components/11.teleports.md +2 -2
- package/{3.api → 4.api}/1.components/12.nuxt-route-announcer.md +1 -3
- package/{3.api → 4.api}/1.components/13.nuxt-time.md +0 -2
- package/{3.api → 4.api}/1.components/2.nuxt-page.md +4 -4
- package/{3.api → 4.api}/1.components/3.nuxt-layout.md +7 -7
- package/{3.api → 4.api}/1.components/4.nuxt-link.md +13 -13
- package/{3.api → 4.api}/1.components/5.nuxt-loading-indicator.md +2 -2
- package/{3.api → 4.api}/1.components/6.nuxt-error-boundary.md +2 -2
- package/{3.api → 4.api}/1.components/7.nuxt-welcome.md +2 -2
- package/{3.api → 4.api}/1.components/8.nuxt-island.md +9 -2
- package/{3.api → 4.api}/2.composables/use-app-config.md +1 -1
- package/{3.api → 4.api}/2.composables/use-async-data.md +5 -5
- package/4.api/2.composables/use-cookie.md +183 -0
- package/{3.api → 4.api}/2.composables/use-error.md +3 -3
- package/{3.api → 4.api}/2.composables/use-fetch.md +37 -37
- package/{3.api → 4.api}/2.composables/use-head-safe.md +1 -1
- package/{3.api → 4.api}/2.composables/use-head.md +22 -7
- package/{3.api → 4.api}/2.composables/use-lazy-async-data.md +1 -1
- package/{3.api → 4.api}/2.composables/use-lazy-fetch.md +9 -9
- package/{3.api → 4.api}/2.composables/use-nuxt-app.md +11 -9
- package/{3.api → 4.api}/2.composables/use-response-header.md +1 -1
- package/{3.api → 4.api}/2.composables/use-route-announcer.md +0 -2
- package/{3.api → 4.api}/2.composables/use-route.md +2 -2
- package/4.api/2.composables/use-router.md +94 -0
- package/{3.api → 4.api}/2.composables/use-runtime-config.md +5 -5
- package/{3.api → 4.api}/2.composables/use-seo-meta.md +2 -2
- package/{3.api → 4.api}/2.composables/use-server-seo-meta.md +2 -2
- package/{3.api → 4.api}/2.composables/use-state.md +12 -2
- package/{3.api → 4.api}/3.utils/$fetch.md +2 -2
- package/{3.api → 4.api}/3.utils/abort-navigation.md +3 -3
- package/{3.api → 4.api}/3.utils/add-route-middleware.md +1 -1
- package/{3.api → 4.api}/3.utils/call-once.md +2 -4
- package/{3.api → 4.api}/3.utils/clear-error.md +1 -1
- package/{3.api → 4.api}/3.utils/create-error.md +7 -7
- package/{3.api → 4.api}/3.utils/define-lazy-hydration-component.md +5 -5
- package/{3.api → 4.api}/3.utils/define-nuxt-component.md +1 -1
- package/{3.api → 4.api}/3.utils/define-nuxt-plugin.md +12 -12
- package/{3.api → 4.api}/3.utils/define-nuxt-route-middleware.md +3 -3
- package/{3.api → 4.api}/3.utils/define-page-meta.md +23 -16
- package/{3.api → 4.api}/3.utils/define-route-rules.md +2 -2
- package/{3.api → 4.api}/3.utils/navigate-to.md +14 -14
- package/{3.api → 4.api}/3.utils/on-before-route-leave.md +1 -1
- package/{3.api → 4.api}/3.utils/on-before-route-update.md +1 -1
- package/{3.api → 4.api}/3.utils/preload-route-components.md +2 -2
- package/{3.api → 4.api}/3.utils/refresh-cookie.md +0 -2
- package/{3.api → 4.api}/3.utils/refresh-nuxt-data.md +1 -1
- package/{3.api → 4.api}/3.utils/reload-nuxt-app.md +1 -1
- package/{3.api → 4.api}/3.utils/set-page-layout.md +36 -0
- package/{3.api → 4.api}/3.utils/set-response-status.md +3 -3
- package/{3.api → 4.api}/3.utils/show-error.md +4 -4
- package/{3.api → 4.api}/3.utils/update-app-config.md +2 -2
- package/{3.api → 4.api}/4.commands/add.md +11 -11
- package/4.api/4.commands/analyze.md +42 -0
- package/4.api/4.commands/build-module.md +42 -0
- package/4.api/4.commands/build.md +47 -0
- package/{3.api → 4.api}/4.commands/cleanup.md +6 -6
- package/4.api/4.commands/dev.md +60 -0
- package/{3.api → 4.api}/4.commands/devtools.md +7 -7
- package/4.api/4.commands/generate.md +42 -0
- package/4.api/4.commands/info.md +33 -0
- package/4.api/4.commands/init.md +50 -0
- package/4.api/4.commands/module.md +84 -0
- package/4.api/4.commands/prepare.md +41 -0
- package/4.api/4.commands/preview.md +44 -0
- package/4.api/4.commands/test.md +40 -0
- package/4.api/4.commands/typecheck.md +44 -0
- package/4.api/4.commands/upgrade.md +37 -0
- package/{3.api → 4.api}/5.kit/1.modules.md +31 -18
- package/{3.api → 4.api}/5.kit/10.templates.md +23 -23
- package/{3.api → 4.api}/5.kit/11.nitro.md +36 -36
- package/{3.api → 4.api}/5.kit/12.resolving.md +2 -2
- package/{3.api → 4.api}/5.kit/14.builder.md +35 -23
- package/{3.api → 4.api}/5.kit/16.layers.md +16 -16
- package/{3.api → 4.api}/5.kit/2.programmatic.md +2 -2
- package/{3.api → 4.api}/5.kit/3.compatibility.md +2 -2
- package/{3.api → 4.api}/5.kit/4.autoimports.md +18 -18
- package/4.api/5.kit/5.components.md +146 -0
- package/{3.api → 4.api}/5.kit/6.context.md +1 -1
- package/{3.api → 4.api}/5.kit/8.layout.md +1 -1
- package/4.api/6.advanced/1.hooks.md +105 -0
- package/{3.api → 4.api}/index.md +7 -7
- package/5.community/4.contribution.md +10 -10
- package/5.community/5.framework-contribution.md +9 -9
- package/5.community/6.roadmap.md +25 -25
- package/5.community/7.changelog.md +20 -0
- package/6.bridge/1.overview.md +9 -1
- package/6.bridge/3.bridge-composition-api.md +2 -2
- package/6.bridge/4.plugins-and-middleware.md +4 -4
- package/6.bridge/5.nuxt3-compatible-api.md +1 -1
- package/6.bridge/8.nitro.md +4 -0
- 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 +3 -3
- package/7.migration/3.auto-imports.md +1 -1
- package/7.migration/4.meta.md +1 -1
- package/7.migration/5.plugins-and-middleware.md +3 -3
- package/7.migration/6.pages-and-layouts.md +9 -9
- package/7.migration/7.component-options.md +6 -6
- package/7.migration/8.runtime-config.md +1 -1
- package/package.json +1 -1
- package/2.guide/0.index.md +0 -25
- package/2.guide/3.going-further/1.features.md +0 -103
- package/2.guide/3.going-further/3.modules.md +0 -901
- package/3.api/2.composables/use-cookie.md +0 -183
- package/3.api/2.composables/use-router.md +0 -94
- package/3.api/4.commands/analyze.md +0 -42
- package/3.api/4.commands/build-module.md +0 -42
- package/3.api/4.commands/build.md +0 -47
- package/3.api/4.commands/dev.md +0 -60
- package/3.api/4.commands/generate.md +0 -42
- package/3.api/4.commands/info.md +0 -33
- package/3.api/4.commands/init.md +0 -50
- package/3.api/4.commands/module.md +0 -84
- package/3.api/4.commands/prepare.md +0 -41
- package/3.api/4.commands/preview.md +0 -44
- package/3.api/4.commands/test.md +0 -40
- package/3.api/4.commands/typecheck.md +0 -44
- package/3.api/4.commands/upgrade.md +0 -37
- package/3.api/5.kit/5.components.md +0 -146
- package/3.api/6.advanced/1.hooks.md +0 -105
- /package/{2.guide/1.directory-structure → 2.directory-structure}/.navigation.yml +0 -0
- /package/{2.guide/1.directory-structure → 2.directory-structure}/2.gitignore.md +0 -0
- /package/{2.guide → 3.guide}/.navigation.yml +0 -0
- /package/{2.guide/2.concepts → 3.guide/1.concepts}/.navigation.yml +0 -0
- /package/{2.guide/5.best-practices → 3.guide/2.best-practices}/.navigation.yml +0 -0
- /package/{2.guide/5.best-practices → 3.guide/2.best-practices}/plugins.md +0 -0
- /package/{2.guide/4.recipes → 3.guide/5.recipes}/.navigation.yml +0 -0
- /package/{2.guide/3.going-further → 3.guide/6.going-further}/.navigation.yml +0 -0
- /package/{2.guide/3.going-further → 3.guide/6.going-further}/index.md +0 -0
- /package/{3.api → 4.api}/.navigation.yml +0 -0
- /package/{3.api → 4.api}/1.components/.navigation.yml +0 -0
- /package/{3.api → 4.api}/1.components/1.client-only.md +0 -0
- /package/{3.api → 4.api}/1.components/1.dev-only.md +0 -0
- /package/{3.api → 4.api}/1.components/9.nuxt-img.md +0 -0
- /package/{3.api → 4.api}/2.composables/.navigation.yml +0 -0
- /package/{3.api → 4.api}/2.composables/on-prehydrate.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-hydration.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-loading-indicator.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-nuxt-data.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-preview-mode.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-request-event.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-request-fetch.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-request-header.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-request-headers.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-request-url.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-runtime-hook.md +0 -0
- /package/{3.api → 4.api}/3.utils/.navigation.yml +0 -0
- /package/{3.api → 4.api}/3.utils/clear-nuxt-data.md +0 -0
- /package/{3.api → 4.api}/3.utils/clear-nuxt-state.md +0 -0
- /package/{3.api → 4.api}/3.utils/on-nuxt-ready.md +0 -0
- /package/{3.api → 4.api}/3.utils/prefetch-components.md +0 -0
- /package/{3.api → 4.api}/3.utils/preload-components.md +0 -0
- /package/{3.api → 4.api}/3.utils/prerender-routes.md +0 -0
- /package/{3.api → 4.api}/4.commands/.navigation.yml +0 -0
- /package/{3.api → 4.api}/5.kit/.navigation.yml +0 -0
- /package/{3.api → 4.api}/5.kit/10.runtime-config.md +0 -0
- /package/{3.api → 4.api}/5.kit/13.logging.md +0 -0
- /package/{3.api → 4.api}/5.kit/15.examples.md +0 -0
- /package/{3.api → 4.api}/5.kit/7.pages.md +0 -0
- /package/{3.api → 4.api}/5.kit/9.head.md +0 -0
- /package/{3.api → 4.api}/5.kit/9.plugins.md +0 -0
- /package/{3.api → 4.api}/6.advanced/.navigation.yml +0 -0
- /package/{3.api → 4.api}/6.advanced/2.import-meta.md +0 -0
- /package/{3.api → 4.api}/6.nuxt-config.md +0 -0
|
@@ -6,7 +6,7 @@ navigation.icon: i-lucide-file-code-2
|
|
|
6
6
|
|
|
7
7
|
Nuxt allows for select pages from your application to be rendered at build time. Nuxt will serve the prebuilt pages when requested instead of generating them on the fly.
|
|
8
8
|
|
|
9
|
-
:read-more{title="Nuxt rendering modes" to="/docs/guide/concepts/rendering"}
|
|
9
|
+
:read-more{title="Nuxt rendering modes" to="/docs/3.x/guide/concepts/rendering"}
|
|
10
10
|
|
|
11
11
|
## Crawl-based Pre-rendering
|
|
12
12
|
|
|
@@ -32,6 +32,10 @@ pnpm nuxt generate
|
|
|
32
32
|
bun x nuxt generate
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
+
```bash [deno]
|
|
36
|
+
deno x nuxt generate
|
|
37
|
+
```
|
|
38
|
+
|
|
35
39
|
::
|
|
36
40
|
|
|
37
41
|
You can now deploy the `.output/public` directory to any static hosting service or preview it locally with `npx serve .output/public`.
|
|
@@ -45,7 +49,7 @@ Working of the Nitro crawler:
|
|
|
45
49
|
|
|
46
50
|
This is important to understand since pages that are not linked to a discoverable page can't be pre-rendered automatically.
|
|
47
51
|
|
|
48
|
-
::read-more{to="/docs/api/commands/generate#nuxt-generate"}
|
|
52
|
+
::read-more{to="/docs/3.x/api/commands/generate#nuxt-generate"}
|
|
49
53
|
Read more about the `nuxt generate` command.
|
|
50
54
|
::
|
|
51
55
|
|
|
@@ -54,6 +58,7 @@ Read more about the `nuxt generate` command.
|
|
|
54
58
|
You can manually specify routes that [Nitro](/docs/3.x/guide/concepts/server-engine) will fetch and pre-render during the build or ignore routes that you don't want to pre-render like `/dynamic` in the `nuxt.config` file:
|
|
55
59
|
|
|
56
60
|
```ts twoslash [nuxt.config.ts]
|
|
61
|
+
// @errors: 2353
|
|
57
62
|
export default defineNuxtConfig({
|
|
58
63
|
nitro: {
|
|
59
64
|
prerender: {
|
|
@@ -67,6 +72,7 @@ export default defineNuxtConfig({
|
|
|
67
72
|
You can combine this with the `crawlLinks` option to pre-render a set of routes that the crawler can't discover like your `/sitemap.xml` or `/robots.txt`:
|
|
68
73
|
|
|
69
74
|
```ts twoslash [nuxt.config.ts]
|
|
75
|
+
// @errors: 2353
|
|
70
76
|
export default defineNuxtConfig({
|
|
71
77
|
nitro: {
|
|
72
78
|
prerender: {
|
|
@@ -105,7 +111,7 @@ Read more about Nitro's `routeRules` configuration.
|
|
|
105
111
|
|
|
106
112
|
As a shorthand, you can also configure this in a page file using [`defineRouteRules`](/docs/3.x/api/utils/define-route-rules).
|
|
107
113
|
|
|
108
|
-
::read-more{to="/docs/guide/going-further/experimental-features#inlinerouterules" icon="i-lucide-star"}
|
|
114
|
+
::read-more{to="/docs/3.x/guide/going-further/experimental-features#inlinerouterules" icon="i-lucide-star"}
|
|
109
115
|
This feature is experimental and in order to use it you must enable the `experimental.inlineRouteRules` option in your `nuxt.config`.
|
|
110
116
|
::
|
|
111
117
|
|
|
@@ -154,7 +160,7 @@ prerenderRoutes('/api/content/article/my-article')
|
|
|
154
160
|
</template>
|
|
155
161
|
```
|
|
156
162
|
|
|
157
|
-
:read-more{title="prerenderRoutes" to="/docs/api/utils/prerender-routes"}
|
|
163
|
+
:read-more{title="prerenderRoutes" to="/docs/3.x/api/utils/prerender-routes"}
|
|
158
164
|
|
|
159
165
|
### `prerender:routes` Nuxt hook
|
|
160
166
|
|
|
@@ -73,7 +73,7 @@ There are two ways to deploy a Nuxt application to any static hosting services:
|
|
|
73
73
|
- Static site generation (SSG) with `ssr: true` pre-renders routes of your application at build time. (This is the default behavior when running `nuxt generate`.) It will also generate `/200.html` and `/404.html` single-page app fallback pages, which can render dynamic routes or 404 errors on the client (though you may need to configure this on your static host).
|
|
74
74
|
- Alternatively, you can prerender your site with `ssr: false` (static single-page app). This will produce HTML pages with an empty `<div id="__nuxt"></div>` where your Vue app would normally be rendered. You will lose many SEO benefits of prerendering your site, so it is suggested instead to use [`<ClientOnly>`](/docs/3.x/api/components/client-only) to wrap the portions of your site that cannot be server rendered (if any).
|
|
75
75
|
|
|
76
|
-
:read-more{title="Nuxt prerendering" to="/docs/getting-started/prerendering"}
|
|
76
|
+
:read-more{title="Nuxt prerendering" to="/docs/3.x/getting-started/prerendering"}
|
|
77
77
|
|
|
78
78
|
### Client-side Only Rendering
|
|
79
79
|
|
|
@@ -95,9 +95,10 @@ Nuxt can be deployed to several cloud providers with a minimal amount of configu
|
|
|
95
95
|
|
|
96
96
|
In addition to Node.js servers and static hosting services, a Nuxt project can be deployed with several well-tested presets and minimal amount of configuration.
|
|
97
97
|
|
|
98
|
-
You can explicitly set the desired preset in the [`nuxt.config.ts`](/docs/3.x/
|
|
98
|
+
You can explicitly set the desired preset in the [`nuxt.config.ts`](/docs/3.x/directory-structure/nuxt-config) file:
|
|
99
99
|
|
|
100
100
|
```ts twoslash [nuxt.config.ts]
|
|
101
|
+
// @errors: 2353
|
|
101
102
|
export default defineNuxtConfig({
|
|
102
103
|
nitro: {
|
|
103
104
|
preset: 'node-server',
|
|
@@ -5,7 +5,7 @@ navigation.icon: i-lucide-circle-check
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
::tip
|
|
8
|
-
If you are a module author, you can find more specific information in the [Module Author's guide](/docs/3.x/guide/
|
|
8
|
+
If you are a module author, you can find more specific information in the [Module Author's guide](/docs/3.x/guide/modules/testing).
|
|
9
9
|
::
|
|
10
10
|
|
|
11
11
|
Nuxt offers first-class support for end-to-end and unit testing of your Nuxt application via `@nuxt/test-utils`, a library of test utilities and configuration that currently powers the [tests we use on Nuxt itself](https://github.com/nuxt/nuxt/tree/main/test) and tests throughout the module ecosystem.
|
|
@@ -63,7 +63,14 @@ We currently ship an environment for unit testing code that needs a [Nuxt](https
|
|
|
63
63
|
{
|
|
64
64
|
test: {
|
|
65
65
|
name: 'unit',
|
|
66
|
-
include: ['test/
|
|
66
|
+
include: ['test/unit/*.{test,spec}.ts'],
|
|
67
|
+
environment: 'node',
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
test: {
|
|
72
|
+
name: 'e2e',
|
|
73
|
+
include: ['test/e2e/*.{test,spec}.ts'],
|
|
67
74
|
environment: 'node',
|
|
68
75
|
},
|
|
69
76
|
},
|
|
@@ -265,9 +272,9 @@ it('can also mount an app', async () => {
|
|
|
265
272
|
|
|
266
273
|
`renderSuspended` allows you to render any Vue component within the Nuxt environment using `@testing-library/vue`, allowing async setup and access to injections from your Nuxt plugins.
|
|
267
274
|
|
|
268
|
-
This should be used together with utilities from Testing Library, e.g. `screen` and `fireEvent`. Install [@testing-library/vue](https://testing-library.com/docs/vue-testing-library/intro) in your project to use these.
|
|
275
|
+
This should be used together with utilities from Testing Library, e.g. `screen` and `fireEvent`. Install [@testing-library/vue](https://testing-library.com/docs/vue-testing-library/intro/) in your project to use these.
|
|
269
276
|
|
|
270
|
-
Additionally, Testing Library also relies on testing globals for cleanup. You should turn these on in your [Vitest config](https://vitest.dev/config
|
|
277
|
+
Additionally, Testing Library also relies on testing globals for cleanup. You should turn these on in your [Vitest config](https://vitest.dev/config/globals).
|
|
271
278
|
|
|
272
279
|
The passed in component will be rendered inside a `<div id="test-wrapper"></div>`.
|
|
273
280
|
|
|
@@ -330,10 +337,10 @@ mockNuxtImport('useStorage', () => {
|
|
|
330
337
|
```
|
|
331
338
|
|
|
332
339
|
::note
|
|
333
|
-
`mockNuxtImport` can only be used once per mocked import per test file. It is actually a macro that gets transformed to `vi.mock` and `vi.mock` is hoisted, as described [in the Vitest docs](https://vitest.dev/api/vi
|
|
340
|
+
`mockNuxtImport` can only be used once per mocked import per test file. It is actually a macro that gets transformed to `vi.mock` and `vi.mock` is hoisted, as described [in the Vitest docs](https://vitest.dev/api/vi#vi-mock).
|
|
334
341
|
::
|
|
335
342
|
|
|
336
|
-
If you need to mock a Nuxt import and provide different implementations between tests, you can do it by creating and exposing your mocks using [`vi.hoisted`](https://vitest.dev/api/vi
|
|
343
|
+
If you need to mock a Nuxt import and provide different implementations between tests, you can do it by creating and exposing your mocks using [`vi.hoisted`](https://vitest.dev/api/vi#vi-hoisted), and then use those mocks in `mockNuxtImport`. You then have access to the mocked imports, and can change the implementation between tests. Be careful to [restore mocks](https://vitest.dev/api/mock#mockrestore) before or after each test to undo mock state changes between runs.
|
|
337
344
|
|
|
338
345
|
```ts twoslash
|
|
339
346
|
import { vi } from 'vitest'
|
|
@@ -624,7 +631,7 @@ Please use the options below for the `setup` method.
|
|
|
624
631
|
- Type: `number | undefined`
|
|
625
632
|
- Default: `undefined`
|
|
626
633
|
|
|
627
|
-
- `host`: If provided, a URL to use as the test target instead of building and running a new server. Useful for running "real" end-to-end tests against a deployed version of your application, or against an already running local server (which may provide a significant reduction in test execution timings). See the [target host end-to-end example below](#target-host-end-to-end-example).
|
|
634
|
+
- `host`: If provided, a URL to use as the test target instead of building and running a new server. Useful for running "real" end-to-end tests against a deployed version of your application, or against an already running local server (which may provide a significant reduction in test execution timings). See the [target host end-to-end example below](/docs/3.x/getting-started/testing#target-host-end-to-end-example).
|
|
628
635
|
- Type: `string`
|
|
629
636
|
- Default: `undefined`
|
|
630
637
|
|
|
@@ -647,7 +654,7 @@ For local development or automated deploy pipelines, testing against a separate
|
|
|
647
654
|
|
|
648
655
|
To utilize a separate target host for end-to-end tests, simply provide the `host` property of the `setup` function with the desired URL.
|
|
649
656
|
|
|
650
|
-
```ts
|
|
657
|
+
```ts
|
|
651
658
|
import { createPage, setup } from '@nuxt/test-utils/e2e'
|
|
652
659
|
import { describe, expect, it } from 'vitest'
|
|
653
660
|
|
|
@@ -730,6 +737,9 @@ pnpm add -D @playwright/test @nuxt/test-utils
|
|
|
730
737
|
```bash [bun]
|
|
731
738
|
bun add --dev @playwright/test @nuxt/test-utils
|
|
732
739
|
```
|
|
740
|
+
```bash [deno]
|
|
741
|
+
deno add --dev npm:@playwright/test npm:@nuxt/test-utils
|
|
742
|
+
```
|
|
733
743
|
::
|
|
734
744
|
|
|
735
745
|
You can provide global Nuxt configuration, with the same configuration details as the `setup()` function mentioned earlier in this section.
|
|
@@ -6,6 +6,35 @@ navigation.icon: i-lucide-circle-arrow-up
|
|
|
6
6
|
|
|
7
7
|
## Upgrading Nuxt
|
|
8
8
|
|
|
9
|
+
### Latest Nuxt 3 release
|
|
10
|
+
|
|
11
|
+
To upgrade Nuxt to the [latest v3 release](https://github.com/nuxt/nuxt/releases), use the `nuxt upgrade` command with `--channel=v3` flag.
|
|
12
|
+
|
|
13
|
+
::code-group{sync="pm"}
|
|
14
|
+
|
|
15
|
+
```bash [npm]
|
|
16
|
+
npx nuxt upgrade --dedupe --channel=v3
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```bash [yarn]
|
|
20
|
+
yarn nuxt upgrade --dedupe --channel=v3
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```bash [pnpm]
|
|
24
|
+
pnpm nuxt upgrade --dedupe --channel=v3
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```bash [bun]
|
|
28
|
+
bun x nuxt upgrade --dedupe --channel=v3
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
::
|
|
32
|
+
|
|
33
|
+
::note
|
|
34
|
+
This will only work if you _already have_ a version of `@nuxt/cli` which has the `--channel` flag implemented. If this does not work, you can instead use `nuxi@latest` for the initial upgrade.
|
|
35
|
+
E.g. `npx nuxi@latest upgrade --dedupe --channel=v3`
|
|
36
|
+
::
|
|
37
|
+
|
|
9
38
|
### Latest release
|
|
10
39
|
|
|
11
40
|
To upgrade Nuxt to the [latest release](https://github.com/nuxt/nuxt/releases), use the `nuxt upgrade` command.
|
|
@@ -28,6 +57,10 @@ pnpm nuxt upgrade
|
|
|
28
57
|
bun x nuxt upgrade
|
|
29
58
|
```
|
|
30
59
|
|
|
60
|
+
```bash [deno]
|
|
61
|
+
deno x nuxt upgrade
|
|
62
|
+
```
|
|
63
|
+
|
|
31
64
|
::
|
|
32
65
|
|
|
33
66
|
### Nightly Release Channel
|
|
@@ -99,46 +132,47 @@ For now, you need to define the compatibility version in each layer that opts in
|
|
|
99
132
|
|
|
100
133
|
When you set your `compatibilityVersion` to `4`, defaults throughout your Nuxt configuration will change to opt in to Nuxt v4 behavior, but you can granularly re-enable Nuxt v3 behavior when testing, following the commented out lines above. Please file issues if so, so that we can address them in Nuxt or in the ecosystem.
|
|
101
134
|
|
|
102
|
-
Breaking or significant changes
|
|
103
|
-
|
|
104
|
-
::note
|
|
105
|
-
This section is subject to change until the final release, so please check back here regularly if you are testing Nuxt 4 using `compatibilityVersion: 4`.
|
|
106
|
-
::
|
|
135
|
+
Breaking or significant changes are documented below along with migration steps and available configuration options.
|
|
107
136
|
|
|
108
137
|
### Migrating Using Codemods
|
|
109
138
|
|
|
110
|
-
To facilitate the upgrade process, we have collaborated with the [Codemod](https://github.com/codemod
|
|
139
|
+
To facilitate the upgrade process, we have collaborated with the [Codemod](https://github.com/codemod/codemod) team to automate many migration steps with some open-source codemods.
|
|
111
140
|
|
|
112
141
|
::note
|
|
113
142
|
If you encounter any issues, please report them to the Codemod team with `npx codemod feedback` 🙏
|
|
114
143
|
::
|
|
115
144
|
|
|
116
|
-
For a complete list of Nuxt 4 codemods, detailed information on each, their source, and various ways to run them, visit the [Codemod Registry](https://
|
|
145
|
+
For a complete list of Nuxt 4 codemods, detailed information on each, their source, and various ways to run them, visit the [Codemod Registry](https://app.codemod.com/registry).
|
|
117
146
|
|
|
118
147
|
You can run all the codemods mentioned in this guide using the following `codemod` recipe:
|
|
119
148
|
|
|
120
149
|
::code-group
|
|
121
150
|
|
|
122
151
|
```bash [npm]
|
|
123
|
-
# Using pinned version due to https://github.com/codemod
|
|
152
|
+
# Using pinned version due to https://github.com/codemod/codemod/issues/1710
|
|
124
153
|
npx codemod@0.18.7 nuxt/4/migration-recipe
|
|
125
154
|
```
|
|
126
155
|
|
|
127
156
|
```bash [yarn]
|
|
128
|
-
# Using pinned version due to https://github.com/codemod
|
|
157
|
+
# Using pinned version due to https://github.com/codemod/codemod/issues/1710
|
|
129
158
|
yarn dlx codemod@0.18.7 nuxt/4/migration-recipe
|
|
130
159
|
```
|
|
131
160
|
|
|
132
161
|
```bash [pnpm]
|
|
133
|
-
# Using pinned version due to https://github.com/codemod
|
|
162
|
+
# Using pinned version due to https://github.com/codemod/codemod/issues/1710
|
|
134
163
|
pnpm dlx codemod@0.18.7 nuxt/4/migration-recipe
|
|
135
164
|
```
|
|
136
165
|
|
|
137
166
|
```bash [bun]
|
|
138
|
-
# Using pinned version due to https://github.com/codemod
|
|
167
|
+
# Using pinned version due to https://github.com/codemod/codemod/issues/1710
|
|
139
168
|
bun x codemod@0.18.7 nuxt/4/migration-recipe
|
|
140
169
|
```
|
|
141
170
|
|
|
171
|
+
```bash [deno]
|
|
172
|
+
# Using pinned version due to https://github.com/codemod/codemod/issues/1710
|
|
173
|
+
deno x codemod@0.18.7 nuxt/4/migration-recipe
|
|
174
|
+
```
|
|
175
|
+
|
|
142
176
|
::
|
|
143
177
|
|
|
144
178
|
This command will execute all codemods in sequence, with the option to deselect any that you do not wish to run. Each codemod is also listed below alongside its respective change and can be executed independently.
|
|
@@ -153,11 +187,11 @@ Nuxt now defaults to a new directory structure, with backwards compatibility (so
|
|
|
153
187
|
|
|
154
188
|
#### What Changed
|
|
155
189
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
190
|
+
- the new Nuxt default `srcDir` is `app/` by default, and most things are resolved from there.
|
|
191
|
+
- `serverDir` now defaults to `<rootDir>/server` rather than `<srcDir>/server`
|
|
192
|
+
- `layers/`, `modules/` and `public/` are resolved relative to `<rootDir>` by default
|
|
193
|
+
- if using [Nuxt Content v2.13+](https://github.com/nuxt/content/pull/2649), `content/` is resolved relative to `<rootDir>`
|
|
194
|
+
- a new `dir.app` is added, which is the directory we look for `router.options.ts` and `spa-loading-template.html` - this defaults to `<srcDir>/`
|
|
161
195
|
|
|
162
196
|
<details>
|
|
163
197
|
|
|
@@ -193,6 +227,10 @@ server/
|
|
|
193
227
|
nuxt.config.ts
|
|
194
228
|
```
|
|
195
229
|
|
|
230
|
+
::note
|
|
231
|
+
With this new structure, the `~` alias now points to the `app/` directory by default (your `srcDir`). This means `~/components` resolves to `components/`, `~/pages` to `pages/`, etc.
|
|
232
|
+
::
|
|
233
|
+
|
|
196
234
|
</details>
|
|
197
235
|
|
|
198
236
|
👉 For more details, see the [PR implementing this change](https://github.com/nuxt/nuxt/pull/27029).
|
|
@@ -318,15 +356,15 @@ Now modules are loaded in the correct order:
|
|
|
318
356
|
2. **Project modules last** (highest priority)
|
|
319
357
|
|
|
320
358
|
This affects both:
|
|
321
|
-
|
|
322
|
-
|
|
359
|
+
- Modules defined in the `modules` array in `nuxt.config.ts`
|
|
360
|
+
- Auto-discovered modules from the `modules/` directory
|
|
323
361
|
|
|
324
362
|
#### Reasons for Change
|
|
325
363
|
|
|
326
364
|
This change ensures that:
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
365
|
+
- Extended layers have lower priority than the consuming project
|
|
366
|
+
- Module execution order matches the intuitive layer inheritance pattern
|
|
367
|
+
- Module configuration and hooks work as expected in multi-layer setups
|
|
330
368
|
|
|
331
369
|
#### Migration Steps
|
|
332
370
|
|
|
@@ -358,7 +396,7 @@ export default defineNuxtConfig({
|
|
|
358
396
|
// 4. project-module-2 (can override layer modules)
|
|
359
397
|
```
|
|
360
398
|
|
|
361
|
-
If you encounter issues with module order dependencies due to needing to register a hook, consider using the [`modules:done` hook](/docs/3.x/guide/
|
|
399
|
+
If you encounter issues with module order dependencies due to needing to register a hook, consider using the [`modules:done` hook](/docs/3.x/guide/modules#custom-hooks) for modules that need to call a hook. This is run after all other modules have been loaded, which means it is safe to use.
|
|
362
400
|
|
|
363
401
|
👉 See [PR #31507](https://github.com/nuxt/nuxt/pull/31507) and [issue #25719](https://github.com/nuxt/nuxt/issues/25719) for more details.
|
|
364
402
|
|
|
@@ -433,9 +471,9 @@ export default defineNuxtConfig({
|
|
|
433
471
|
[Unhead](https://unhead.unjs.io/), used to generate `<head>` tags, has been updated to version 2. While mostly compatible it includes several breaking changes
|
|
434
472
|
for lower-level APIs.
|
|
435
473
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
474
|
+
- Removed props: `vmid`, `hid`, `children`, `body`.
|
|
475
|
+
- Promise input no longer supported.
|
|
476
|
+
- Tags are now sorted using Capo.js by default.
|
|
439
477
|
|
|
440
478
|
#### Migration Steps
|
|
441
479
|
|
|
@@ -443,7 +481,7 @@ The above changes should have minimal impact on your app.
|
|
|
443
481
|
|
|
444
482
|
If you have issues you should verify:
|
|
445
483
|
|
|
446
|
-
|
|
484
|
+
- You're not using any of the removed props.
|
|
447
485
|
|
|
448
486
|
```diff
|
|
449
487
|
useHead({
|
|
@@ -456,7 +494,7 @@ useHead({
|
|
|
456
494
|
})
|
|
457
495
|
```
|
|
458
496
|
|
|
459
|
-
|
|
497
|
+
- If you're using [Template Params](https://unhead.unjs.io/docs/head/guides/plugins/template-params) or [Alias Tag Sorting](https://unhead.unjs.io/docs/head/guides/plugins/alias-sorting), you will need to explicitly opt in to these features now.
|
|
460
498
|
|
|
461
499
|
```ts
|
|
462
500
|
import { AliasSortingPlugin, TemplateParamsPlugin } from '@unhead/vue/plugins'
|
|
@@ -493,7 +531,7 @@ export default defineNuxtConfig({
|
|
|
493
531
|
|
|
494
532
|
#### What Changed
|
|
495
533
|
|
|
496
|
-
When rendering a client-only page (with `ssr: false`), we optionally render a loading screen (from
|
|
534
|
+
When rendering a client-only page (with `ssr: false`), we optionally render a loading screen (from `~/app/spa-loading-template.html` - note that this has also changed to `~/spa-loading-template.html` in Nuxt 4), within the Nuxt app root:
|
|
497
535
|
|
|
498
536
|
```html
|
|
499
537
|
<div id="__nuxt">
|
|
@@ -638,7 +676,7 @@ For example, if your site requires a `useFetch` call for every page (for example
|
|
|
638
676
|
|
|
639
677
|
Make sure that any unique key of your data is always resolvable to the same data. For example, if you are using `useAsyncData` to fetch data related to a particular page, you should provide a key that uniquely matches that data. (`useFetch` should do this automatically for you.)
|
|
640
678
|
|
|
641
|
-
```ts [
|
|
679
|
+
```ts [pages/test/[slug\\].vue]
|
|
642
680
|
// This would be unsafe in a dynamic page (e.g. `[slug].vue`) because the route slug makes a difference
|
|
643
681
|
// to the data fetched, but Nuxt can't know that because it's not reflected in the key.
|
|
644
682
|
const route = useRoute()
|
|
@@ -989,15 +1027,15 @@ In Nuxt v3 we moved to a 'virtual' syntax with a `getContents()` function which
|
|
|
989
1027
|
|
|
990
1028
|
In addition, `lodash/template` has had a succession of security issues. These do not really apply to Nuxt projects because it is being used at build-time, not runtime, and by trusted code. However, they still appear in security audits. Moreover, `lodash` is a hefty dependency and is unused by most projects.
|
|
991
1029
|
|
|
992
|
-
Finally, providing code serialization functions directly within Nuxt is not ideal. Instead, we maintain projects like [unjs/knitwork](
|
|
1030
|
+
Finally, providing code serialization functions directly within Nuxt is not ideal. Instead, we maintain projects like [unjs/knitwork](https://github.com/unjs/knitwork) which can be dependencies of your project, and where security issues can be reported/resolved directly without requiring an upgrade of Nuxt itself.
|
|
993
1031
|
|
|
994
1032
|
#### Migration Steps
|
|
995
1033
|
|
|
996
1034
|
We have raised PRs to update modules using EJS syntax, but if you need to do this yourself, you have three backwards/forwards-compatible alternatives:
|
|
997
1035
|
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1036
|
+
- Moving your string interpolation logic directly into `getContents()`.
|
|
1037
|
+
- Using a custom function to handle the replacement, such as in https://github.com/nuxt-modules/color-mode/pull/240.
|
|
1038
|
+
- Use `es-toolkit/compat` (a drop-in replacement for lodash template), as a dependency of _your_ project rather than Nuxt:
|
|
1001
1039
|
|
|
1002
1040
|
```diff
|
|
1003
1041
|
+ import { readFileSync } from 'node:fs'
|
|
@@ -1080,11 +1118,11 @@ There are two approaches:
|
|
|
1080
1118
|
Nuxt now generates separate TypeScript configurations for different contexts to provide better type-checking experiences:
|
|
1081
1119
|
|
|
1082
1120
|
1. **New TypeScript configuration files**: Nuxt now generates additional TypeScript configurations:
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1121
|
+
- `.nuxt/tsconfig.app.json` - For your app code (Vue components, composables, etc.)
|
|
1122
|
+
- `.nuxt/tsconfig.server.json` - For your server-side code (Nitro/server directory)
|
|
1123
|
+
- `.nuxt/tsconfig.node.json` - For your build-time code (modules, `nuxt.config.ts`, etc.)
|
|
1124
|
+
- `.nuxt/tsconfig.shared.json` - For code shared between app and server contexts (like types and non-environment specific utilities)
|
|
1125
|
+
- `.nuxt/tsconfig.json` - Legacy configuration for backward compatibility
|
|
1088
1126
|
|
|
1089
1127
|
2. **Backward compatibility**: Existing projects that extend `.nuxt/tsconfig.json` will continue to work as before.
|
|
1090
1128
|
|
|
@@ -1113,8 +1151,13 @@ However, to take advantage of improved type checking, you can opt in to the new
|
|
|
1113
1151
|
|
|
1114
1152
|
1. **Update your root `tsconfig.json`** to use project references:
|
|
1115
1153
|
|
|
1154
|
+
::note
|
|
1155
|
+
If your `tsconfig.json` currently has an `"extends": "./.nuxt/tsconfig.json"` line, **remove it** before adding the references. Project references and extends are mutually exclusive.
|
|
1156
|
+
::
|
|
1157
|
+
|
|
1116
1158
|
```json
|
|
1117
1159
|
{
|
|
1160
|
+
// Remove "extends": "./.nuxt/tsconfig.json" if present
|
|
1118
1161
|
"files": [],
|
|
1119
1162
|
"references": [
|
|
1120
1163
|
{ "path": "./.nuxt/tsconfig.app.json" },
|
|
@@ -1135,30 +1178,38 @@ However, to take advantage of improved type checking, you can opt in to the new
|
|
|
1135
1178
|
```
|
|
1136
1179
|
|
|
1137
1180
|
4. **Move all type augmentations into their appropriate context**:
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1181
|
+
- If you are augmenting types for the app context, move the files to the `app/` directory.
|
|
1182
|
+
- If you are augmenting types for the server context, move the files to the `server/` directory.
|
|
1183
|
+
- If you are augmenting types that are **shared between the app and server**, move the files to the `shared/` directory.
|
|
1141
1184
|
|
|
1142
1185
|
::warning
|
|
1143
1186
|
Augmenting types from outside the `app/`, `server/`, or `shared/` directories will not work with the new project references setup.
|
|
1144
1187
|
::
|
|
1145
1188
|
|
|
1146
|
-
5. **Configure
|
|
1189
|
+
5. **Configure TypeScript options** if needed:
|
|
1147
1190
|
<!-- @case-police-ignore tsConfig -->
|
|
1148
1191
|
|
|
1149
1192
|
```ts
|
|
1150
1193
|
export default defineNuxtConfig({
|
|
1151
1194
|
typescript: {
|
|
1152
|
-
//
|
|
1195
|
+
// customize tsconfig.app.json
|
|
1153
1196
|
tsConfig: {
|
|
1154
|
-
|
|
1155
|
-
strict: true,
|
|
1156
|
-
},
|
|
1197
|
+
// ...
|
|
1157
1198
|
},
|
|
1158
|
-
//
|
|
1199
|
+
// customize tsconfig.shared.json
|
|
1200
|
+
sharedTsConfig: {
|
|
1201
|
+
// ...
|
|
1202
|
+
},
|
|
1203
|
+
// customize tsconfig.node.json
|
|
1159
1204
|
nodeTsConfig: {
|
|
1160
|
-
|
|
1161
|
-
|
|
1205
|
+
// ...
|
|
1206
|
+
},
|
|
1207
|
+
},
|
|
1208
|
+
nitro: {
|
|
1209
|
+
typescript: {
|
|
1210
|
+
// customize tsconfig.server.json
|
|
1211
|
+
tsConfig: {
|
|
1212
|
+
// ...
|
|
1162
1213
|
},
|
|
1163
1214
|
},
|
|
1164
1215
|
},
|
|
@@ -1177,11 +1228,11 @@ The new configuration provides better type safety and IntelliSense for projects
|
|
|
1177
1228
|
|
|
1178
1229
|
Four experimental features are no longer configurable in Nuxt 4:
|
|
1179
1230
|
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1231
|
+
- `experimental.treeshakeClientOnly` will be `true` (default since v3.0)
|
|
1232
|
+
- `experimental.configSchema` will be `true` (default since v3.3)
|
|
1233
|
+
- `experimental.polyfillVueUseHead` will be `false` (default since v3.4)
|
|
1234
|
+
- `experimental.respectNoSSRHeader` will be `false` (default since v3.4)
|
|
1235
|
+
- `vite.devBundler` is no longer configurable - it will use `vite-node` by default
|
|
1185
1236
|
|
|
1186
1237
|
#### Reasons for Change
|
|
1187
1238
|
|
|
@@ -1189,9 +1240,9 @@ These options have been set to their current values for some time and we do not
|
|
|
1189
1240
|
|
|
1190
1241
|
#### Migration Steps
|
|
1191
1242
|
|
|
1192
|
-
|
|
1243
|
+
- `polyfillVueUseHead` is implementable in user-land with [this plugin](https://github.com/nuxt/nuxt/blob/f209158352b09d1986aa320e29ff36353b91c358/packages/nuxt/src/head/runtime/plugins/vueuse-head-polyfill.ts#L10-L11)
|
|
1193
1244
|
|
|
1194
|
-
|
|
1245
|
+
- `respectNoSSRHeader`is implementable in user-land with [server middleware](https://github.com/nuxt/nuxt/blob/c660b39447f0d5b8790c0826092638d321cd6821/packages/nuxt/src/core/runtime/nitro/no-ssr.ts#L8-L9)
|
|
1195
1246
|
|
|
1196
1247
|
### Removal of Top-Level `generate` Configuration
|
|
1197
1248
|
|
|
@@ -1201,8 +1252,8 @@ These options have been set to their current values for some time and we do not
|
|
|
1201
1252
|
|
|
1202
1253
|
The top-level `generate` configuration option is no longer available in Nuxt 4. This includes all of its properties:
|
|
1203
1254
|
|
|
1204
|
-
|
|
1205
|
-
|
|
1255
|
+
- `generate.exclude` - for excluding routes from prerendering
|
|
1256
|
+
- `generate.routes` - for specifying routes to prerender
|
|
1206
1257
|
|
|
1207
1258
|
#### Reasons for Change
|
|
1208
1259
|
|
|
@@ -1257,7 +1308,7 @@ Static sites | ✅ | ✅ | ✅
|
|
|
1257
1308
|
|
|
1258
1309
|
The migration guide provides a step-by-step comparison of Nuxt 2 features to Nuxt 3+ features and guidance to adapt your current application.
|
|
1259
1310
|
|
|
1260
|
-
::read-more{to="/docs/migration/overview"}
|
|
1311
|
+
::read-more{to="/docs/3.x/migration/overview"}
|
|
1261
1312
|
Check out the **guide to migrating from Nuxt 2 to Nuxt 3**.
|
|
1262
1313
|
::
|
|
1263
1314
|
|
|
@@ -1265,6 +1316,6 @@ Check out the **guide to migrating from Nuxt 2 to Nuxt 3**.
|
|
|
1265
1316
|
|
|
1266
1317
|
If you prefer to progressively migrate your Nuxt 2 application to Nuxt 3, you can use Nuxt Bridge. Nuxt Bridge is a compatibility layer that allows you to use Nuxt 3+ features in Nuxt 2 with an opt-in mechanism.
|
|
1267
1318
|
|
|
1268
|
-
::read-more{to="/docs/bridge/overview"}
|
|
1319
|
+
::read-more{to="/docs/3.x/bridge/overview"}
|
|
1269
1320
|
**Migrate from Nuxt 2 to Nuxt Bridge**
|
|
1270
1321
|
::
|
|
@@ -6,7 +6,7 @@ navigation.icon: i-vscode-icons-folder-type-temp
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
::important
|
|
9
|
-
This directory should be added to your [`.gitignore`](/docs/3.x/
|
|
9
|
+
This directory should be added to your [`.gitignore`](/docs/3.x/directory-structure/gitignore) file to avoid pushing the dev build output to your repository.
|
|
10
10
|
::
|
|
11
11
|
|
|
12
12
|
This directory is interesting if you want to learn more about the files Nuxt generates based on your directory structure.
|
|
@@ -6,12 +6,12 @@ navigation.icon: i-vscode-icons-folder-type-package
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
::important
|
|
9
|
-
This directory should be added to your [`.gitignore`](/docs/3.x/
|
|
9
|
+
This directory should be added to your [`.gitignore`](/docs/3.x/directory-structure/gitignore) file to avoid pushing the build output to your repository.
|
|
10
10
|
::
|
|
11
11
|
|
|
12
12
|
Use this directory to deploy your Nuxt application to production.
|
|
13
13
|
|
|
14
|
-
:read-more{to="/docs/getting-started/deployment"}
|
|
14
|
+
:read-more{to="/docs/3.x/getting-started/deployment"}
|
|
15
15
|
|
|
16
16
|
::warning
|
|
17
17
|
You should not touch any files inside since the whole directory will be re-created when running [`nuxt build`](/docs/3.x/api/commands/build).
|
|
@@ -9,8 +9,8 @@ The directory usually contains the following types of files:
|
|
|
9
9
|
|
|
10
10
|
- Stylesheets (CSS, SASS, etc.)
|
|
11
11
|
- Fonts
|
|
12
|
-
- Images that won't be served from the [`public/`](/docs/3.x/
|
|
12
|
+
- Images that won't be served from the [`public/`](/docs/3.x/directory-structure/public) directory.
|
|
13
13
|
|
|
14
|
-
If you want to serve assets from the server, we recommend taking a look at the [`public/`](/docs/3.x/
|
|
14
|
+
If you want to serve assets from the server, we recommend taking a look at the [`public/`](/docs/3.x/directory-structure/public) directory.
|
|
15
15
|
|
|
16
|
-
:read-more{to="/docs/getting-started/assets"}
|
|
16
|
+
:read-more{to="/docs/3.x/getting-started/assets"}
|