@nuxt/docs 4.1.2 → 4.2.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 +6 -6
- package/1.getting-started/02.installation.md +3 -2
- package/1.getting-started/03.configuration.md +36 -36
- package/1.getting-started/04.views.md +9 -9
- package/1.getting-started/05.assets.md +15 -9
- package/1.getting-started/06.styling.md +58 -48
- package/1.getting-started/07.routing.md +17 -17
- package/1.getting-started/08.seo-meta.md +59 -46
- package/1.getting-started/09.transitions.md +49 -44
- package/1.getting-started/10.data-fetching.md +104 -81
- package/1.getting-started/11.state-management.md +26 -19
- package/1.getting-started/12.error-handling.md +22 -20
- package/1.getting-started/13.server.md +8 -8
- package/1.getting-started/14.layers.md +22 -16
- package/1.getting-started/15.prerendering.md +32 -32
- package/1.getting-started/16.deployment.md +10 -10
- package/1.getting-started/17.testing.md +44 -44
- package/1.getting-started/18.upgrade.md +241 -110
- package/2.guide/0.index.md +7 -7
- package/2.guide/{2.directory-structure → 1.directory-structure}/.navigation.yml +1 -1
- package/2.guide/{2.directory-structure → 1.directory-structure}/0.nuxt.md +3 -3
- package/2.guide/1.directory-structure/0.output.md +18 -0
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/.navigation.yml +1 -1
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.assets.md +4 -4
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.components.md +45 -28
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.composables.md +13 -13
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.layouts.md +19 -15
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.middleware.md +31 -25
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.pages.md +39 -37
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.plugins.md +25 -25
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/1.utils.md +7 -7
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/3.app-config.md +18 -18
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/3.app.md +7 -7
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.app/3.error.md +6 -6
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.content.md +7 -4
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.modules.md +8 -8
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.node_modules.md +2 -2
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.public.md +2 -2
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.server.md +35 -35
- package/2.guide/{2.directory-structure → 1.directory-structure}/1.shared.md +7 -7
- package/2.guide/{2.directory-structure → 1.directory-structure}/2.env.md +8 -8
- package/2.guide/{2.directory-structure → 1.directory-structure}/2.gitignore.md +1 -1
- package/2.guide/{2.directory-structure → 1.directory-structure}/2.nuxtignore.md +5 -4
- package/2.guide/{2.directory-structure → 1.directory-structure}/2.nuxtrc.md +4 -4
- package/2.guide/{2.directory-structure → 1.directory-structure}/3.nuxt-config.md +3 -3
- package/2.guide/{2.directory-structure → 1.directory-structure}/3.package.md +1 -1
- package/2.guide/{2.directory-structure → 1.directory-structure}/3.tsconfig.md +3 -3
- package/2.guide/{1.concepts → 2.concepts}/1.auto-imports.md +22 -22
- package/2.guide/{1.concepts → 2.concepts}/10.nuxt-lifecycle.md +17 -17
- package/2.guide/{1.concepts → 2.concepts}/2.vuejs-development.md +13 -13
- package/2.guide/{1.concepts → 2.concepts}/3.rendering.md +24 -22
- package/2.guide/{1.concepts → 2.concepts}/4.server-engine.md +6 -6
- package/2.guide/{1.concepts → 2.concepts}/5.modules.md +5 -5
- package/2.guide/{1.concepts → 2.concepts}/7.esm.md +22 -16
- package/2.guide/{1.concepts → 2.concepts}/8.typescript.md +12 -12
- package/2.guide/3.going-further/1.events.md +3 -3
- package/2.guide/3.going-further/1.experimental-features.md +334 -85
- package/2.guide/3.going-further/1.features.md +58 -11
- package/2.guide/3.going-further/1.internals.md +25 -25
- package/2.guide/3.going-further/10.runtime-config.md +12 -12
- package/2.guide/3.going-further/11.nightly-release-channel.md +1 -1
- package/2.guide/3.going-further/2.hooks.md +14 -14
- package/2.guide/3.going-further/3.modules.md +126 -108
- package/2.guide/3.going-further/4.kit.md +7 -7
- package/2.guide/3.going-further/6.nuxt-app.md +8 -8
- package/2.guide/3.going-further/7.layers.md +76 -59
- package/2.guide/3.going-further/9.debugging.md +2 -2
- package/2.guide/4.recipes/1.custom-routing.md +30 -30
- package/2.guide/4.recipes/2.vite-plugin.md +45 -4
- package/2.guide/4.recipes/3.custom-usefetch.md +13 -13
- package/2.guide/4.recipes/4.sessions-and-authentication.md +35 -21
- package/2.guide/5.best-practices/hydration.md +4 -4
- package/2.guide/5.best-practices/performance.md +17 -17
- package/3.api/1.components/1.client-only.md +6 -3
- package/3.api/1.components/1.nuxt-client-fallback.md +10 -7
- package/3.api/1.components/10.nuxt-picture.md +1 -1
- package/3.api/1.components/11.teleports.md +5 -2
- package/3.api/1.components/12.nuxt-route-announcer.md +9 -9
- package/3.api/1.components/13.nuxt-time.md +49 -18
- package/3.api/1.components/2.nuxt-page.md +6 -6
- package/3.api/1.components/3.nuxt-layout.md +15 -10
- package/3.api/1.components/4.nuxt-link.md +42 -22
- package/3.api/1.components/5.nuxt-loading-indicator.md +3 -3
- package/3.api/1.components/6.nuxt-error-boundary.md +12 -10
- package/3.api/2.composables/on-prehydrate.md +2 -2
- package/3.api/2.composables/use-app-config.md +1 -1
- package/3.api/2.composables/use-async-data.md +26 -22
- package/3.api/2.composables/use-cookie.md +29 -21
- package/3.api/2.composables/use-error.md +2 -2
- package/3.api/2.composables/use-fetch.md +62 -32
- package/3.api/2.composables/use-head-safe.md +7 -7
- package/3.api/2.composables/use-head.md +5 -5
- package/3.api/2.composables/use-hydration.md +6 -6
- package/3.api/2.composables/use-lazy-async-data.md +4 -4
- package/3.api/2.composables/use-lazy-fetch.md +4 -4
- package/3.api/2.composables/use-loading-indicator.md +12 -12
- package/3.api/2.composables/use-nuxt-app.md +22 -22
- package/3.api/2.composables/use-nuxt-data.md +8 -8
- package/3.api/2.composables/use-preview-mode.md +15 -18
- package/3.api/2.composables/use-request-event.md +1 -1
- package/3.api/2.composables/use-request-fetch.md +3 -3
- package/3.api/2.composables/use-request-header.md +1 -1
- package/3.api/2.composables/use-request-headers.md +4 -4
- package/3.api/2.composables/use-request-url.md +1 -1
- package/3.api/2.composables/use-response-header.md +9 -10
- package/3.api/2.composables/use-route-announcer.md +4 -4
- package/3.api/2.composables/use-route.md +1 -1
- package/3.api/2.composables/use-router.md +10 -8
- package/3.api/2.composables/use-runtime-config.md +11 -11
- package/3.api/2.composables/use-runtime-hook.md +2 -2
- package/3.api/2.composables/use-seo-meta.md +4 -4
- package/3.api/2.composables/use-server-seo-meta.md +6 -6
- package/3.api/2.composables/use-state.md +5 -5
- package/3.api/3.utils/$fetch.md +10 -8
- package/3.api/3.utils/abort-navigation.md +3 -3
- package/3.api/3.utils/add-route-middleware.md +5 -5
- package/3.api/3.utils/call-once.md +6 -6
- package/3.api/3.utils/clear-error.md +3 -3
- package/3.api/3.utils/clear-nuxt-data.md +3 -3
- package/3.api/3.utils/clear-nuxt-state.md +3 -3
- package/3.api/3.utils/create-error.md +2 -2
- package/3.api/3.utils/define-lazy-hydration-component.md +13 -13
- package/3.api/3.utils/define-nuxt-component.md +5 -5
- package/3.api/3.utils/define-nuxt-plugin.md +13 -13
- package/3.api/3.utils/define-nuxt-route-middleware.md +5 -5
- package/3.api/3.utils/define-page-meta.md +23 -23
- package/3.api/3.utils/define-route-rules.md +7 -7
- package/3.api/3.utils/navigate-to.md +11 -11
- package/3.api/3.utils/prefetch-components.md +1 -1
- package/3.api/3.utils/preload-components.md +1 -1
- package/3.api/3.utils/preload-route-components.md +2 -2
- package/3.api/3.utils/prerender-routes.md +3 -3
- package/3.api/3.utils/refresh-cookie.md +4 -4
- package/3.api/3.utils/refresh-nuxt-data.md +12 -7
- package/3.api/3.utils/reload-nuxt-app.md +3 -3
- package/3.api/3.utils/set-page-layout.md +1 -1
- package/3.api/3.utils/set-response-status.md +3 -3
- package/3.api/3.utils/show-error.md +5 -5
- package/3.api/3.utils/update-app-config.md +4 -3
- package/3.api/4.commands/add.md +1 -1
- package/3.api/4.commands/analyze.md +2 -1
- package/3.api/4.commands/build.md +2 -1
- package/3.api/4.commands/dev.md +5 -4
- package/3.api/4.commands/generate.md +3 -2
- package/3.api/4.commands/init.md +3 -2
- package/3.api/4.commands/module.md +4 -4
- package/3.api/4.commands/prepare.md +7 -2
- package/3.api/4.commands/preview.md +5 -4
- package/3.api/4.commands/test.md +40 -0
- package/3.api/4.commands/typecheck.md +5 -3
- package/3.api/4.commands/upgrade.md +3 -3
- package/3.api/5.kit/1.modules.md +123 -37
- package/3.api/5.kit/10.runtime-config.md +1 -1
- package/3.api/5.kit/10.templates.md +8 -6
- package/3.api/5.kit/11.nitro.md +66 -62
- package/3.api/5.kit/12.resolving.md +2 -2
- package/3.api/5.kit/14.builder.md +61 -4
- package/3.api/5.kit/15.examples.md +5 -7
- package/3.api/5.kit/16.layers.md +26 -26
- package/3.api/5.kit/3.compatibility.md +14 -14
- package/3.api/5.kit/4.autoimports.md +13 -13
- package/3.api/5.kit/5.components.md +8 -7
- package/3.api/5.kit/6.context.md +3 -3
- package/3.api/5.kit/7.pages.md +7 -7
- package/3.api/5.kit/8.layout.md +2 -2
- package/3.api/5.kit/9.head.md +132 -0
- package/3.api/5.kit/9.plugins.md +5 -4
- package/3.api/6.advanced/1.hooks.md +5 -5
- package/3.api/6.advanced/2.import-meta.md +3 -3
- package/3.api/6.nuxt-config.md +365 -859
- package/3.api/index.md +7 -7
- package/5.community/2.getting-help.md +1 -1
- package/5.community/3.reporting-bugs.md +3 -3
- package/5.community/4.contribution.md +11 -11
- package/5.community/5.framework-contribution.md +4 -4
- package/5.community/6.roadmap.md +2 -2
- package/6.bridge/1.overview.md +13 -13
- package/6.bridge/10.configuration.md +2 -1
- package/6.bridge/2.typescript.md +3 -3
- package/6.bridge/3.bridge-composition-api.md +8 -8
- package/6.bridge/4.plugins-and-middleware.md +9 -9
- package/6.bridge/5.nuxt3-compatible-api.md +20 -17
- package/6.bridge/6.meta.md +20 -19
- package/6.bridge/7.runtime-config.md +1 -1
- package/6.bridge/8.nitro.md +3 -3
- package/6.bridge/9.vite.md +4 -4
- 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 +23 -21
- package/7.migration/20.module-authors.md +7 -7
- package/7.migration/3.auto-imports.md +3 -3
- package/7.migration/4.meta.md +21 -18
- package/7.migration/5.plugins-and-middleware.md +8 -8
- package/7.migration/6.pages-and-layouts.md +28 -24
- package/7.migration/7.component-options.md +18 -18
- package/7.migration/8.runtime-config.md +7 -7
- package/package.json +1 -1
- package/2.guide/2.directory-structure/0.output.md +0 -18
- /package/2.guide/{1.concepts → 2.concepts}/.navigation.yml +0 -0
- /package/2.guide/{1.concepts → 2.concepts}/9.code-style.md +0 -0
package/3.api/6.nuxt-config.md
CHANGED
|
@@ -36,15 +36,15 @@ your alias by prefixing it with `~`.
|
|
|
36
36
|
::
|
|
37
37
|
|
|
38
38
|
**Example**:
|
|
39
|
-
```
|
|
40
|
-
import { fileURLToPath } from
|
|
39
|
+
```ts
|
|
40
|
+
import { fileURLToPath } from 'node:url'
|
|
41
41
|
|
|
42
42
|
export default defineNuxtConfig({
|
|
43
43
|
alias: {
|
|
44
44
|
'images': fileURLToPath(new URL('./assets/images', import.meta.url)),
|
|
45
45
|
'style': fileURLToPath(new URL('./assets/style', import.meta.url)),
|
|
46
|
-
'data': fileURLToPath(new URL('./assets/other/data', import.meta.url))
|
|
47
|
-
}
|
|
46
|
+
'data': fileURLToPath(new URL('./assets/other/data', import.meta.url)),
|
|
47
|
+
},
|
|
48
48
|
})
|
|
49
49
|
```
|
|
50
50
|
|
|
@@ -94,8 +94,8 @@ For example:
|
|
|
94
94
|
```ts
|
|
95
95
|
export default defineNuxtConfig({
|
|
96
96
|
app: {
|
|
97
|
-
baseURL: '/prefix/'
|
|
98
|
-
}
|
|
97
|
+
baseURL: '/prefix/',
|
|
98
|
+
},
|
|
99
99
|
})
|
|
100
100
|
```
|
|
101
101
|
|
|
@@ -126,8 +126,8 @@ For example:
|
|
|
126
126
|
```ts
|
|
127
127
|
export default defineNuxtConfig({
|
|
128
128
|
app: {
|
|
129
|
-
cdnURL: 'https://mycdn.org/'
|
|
130
|
-
}
|
|
129
|
+
cdnURL: 'https://mycdn.org/',
|
|
130
|
+
},
|
|
131
131
|
})
|
|
132
132
|
```
|
|
133
133
|
|
|
@@ -163,32 +163,34 @@ Set default configuration for `<head>` on every page.
|
|
|
163
163
|
```
|
|
164
164
|
|
|
165
165
|
**Example**:
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
```ts
|
|
167
|
+
export default defineNuxtConfig({
|
|
168
|
+
app: {
|
|
169
|
+
head: {
|
|
170
|
+
meta: [
|
|
170
171
|
// <meta name="viewport" content="width=device-width, initial-scale=1">
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
|
|
173
|
+
],
|
|
174
|
+
script: [
|
|
174
175
|
// <script src="https://myawesome-lib.js"></script>
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
176
|
+
{ src: 'https://awesome-lib.js' },
|
|
177
|
+
],
|
|
178
|
+
link: [
|
|
178
179
|
// <link rel="stylesheet" href="https://myawesome-lib.css">
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
180
|
+
{ rel: 'stylesheet', href: 'https://awesome-lib.css' },
|
|
181
|
+
],
|
|
182
|
+
// please note that this is an area that is likely to change
|
|
183
|
+
style: [
|
|
183
184
|
// <style>:root { color: red }</style>
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
{ textContent: ':root { color: red }' },
|
|
186
|
+
],
|
|
187
|
+
noscript: [
|
|
187
188
|
// <noscript>JavaScript is required</noscript>
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
189
|
+
{ textContent: 'JavaScript is required' },
|
|
190
|
+
],
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
})
|
|
192
194
|
```
|
|
193
195
|
|
|
194
196
|
### `keepalive`
|
|
@@ -304,13 +306,13 @@ Customize Nuxt Teleport element tag.
|
|
|
304
306
|
|
|
305
307
|
Default values for view transitions.
|
|
306
308
|
|
|
307
|
-
This only has an effect when **experimental** support for View Transitions is [enabled in your nuxt.config file](/docs/getting-started/transitions#view-transitions-api-experimental).
|
|
309
|
+
This only has an effect when **experimental** support for View Transitions is [enabled in your nuxt.config file](/docs/4.x/getting-started/transitions#view-transitions-api-experimental).
|
|
308
310
|
This can be overridden with `definePageMeta` on an individual page.
|
|
309
311
|
|
|
310
312
|
- **Type**: `boolean`
|
|
311
313
|
- **Default:** `false`
|
|
312
314
|
|
|
313
|
-
**See**: [Nuxt View Transition API docs](https://nuxt.com/docs/getting-started/transitions#view-transitions-api-experimental)
|
|
315
|
+
**See**: [Nuxt View Transition API docs](https://nuxt.com/docs/4.x/getting-started/transitions#view-transitions-api-experimental)
|
|
314
316
|
|
|
315
317
|
## appConfig
|
|
316
318
|
|
|
@@ -350,10 +352,12 @@ Set to `true` to enable bundle analysis, or pass an object with options: [for we
|
|
|
350
352
|
```
|
|
351
353
|
|
|
352
354
|
**Example**:
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
355
|
+
```ts
|
|
356
|
+
export default defineNuxtConfig({
|
|
357
|
+
analyze: {
|
|
358
|
+
analyzerMode: 'static',
|
|
359
|
+
},
|
|
360
|
+
})
|
|
357
361
|
```
|
|
358
362
|
|
|
359
363
|
### `templates`
|
|
@@ -363,13 +367,17 @@ It is recommended to use `addTemplate` from `@nuxt/kit` instead of this option.
|
|
|
363
367
|
- **Type**: `array`
|
|
364
368
|
|
|
365
369
|
**Example**:
|
|
366
|
-
```
|
|
367
|
-
|
|
368
|
-
{
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
370
|
+
```ts
|
|
371
|
+
export default defineNuxtConfig({
|
|
372
|
+
build: {
|
|
373
|
+
templates: [
|
|
374
|
+
{
|
|
375
|
+
src: '~/modules/support/plugin.js', // `src` can be absolute or relative
|
|
376
|
+
dst: 'support.js', // `dst` is relative to project `.nuxt` dir
|
|
377
|
+
},
|
|
378
|
+
],
|
|
379
|
+
},
|
|
380
|
+
})
|
|
373
381
|
```
|
|
374
382
|
|
|
375
383
|
### `transpile`
|
|
@@ -381,8 +389,12 @@ You can also use a function to conditionally transpile. The function will receiv
|
|
|
381
389
|
- **Type**: `array`
|
|
382
390
|
|
|
383
391
|
**Example**:
|
|
384
|
-
```
|
|
385
|
-
|
|
392
|
+
```ts
|
|
393
|
+
export default defineNuxtConfig({
|
|
394
|
+
build: {
|
|
395
|
+
transpile: [({ isLegacy }) => isLegacy && 'ky'],
|
|
396
|
+
},
|
|
397
|
+
})
|
|
386
398
|
```
|
|
387
399
|
|
|
388
400
|
## buildDir
|
|
@@ -395,10 +407,10 @@ Many tools assume that `.nuxt` is a hidden directory (because it starts with a `
|
|
|
395
407
|
- **Default:** `"/<rootDir>/.nuxt"`
|
|
396
408
|
|
|
397
409
|
**Example**:
|
|
398
|
-
```
|
|
399
|
-
export default {
|
|
400
|
-
buildDir: 'nuxt-build'
|
|
401
|
-
}
|
|
410
|
+
```ts
|
|
411
|
+
export default defineNuxtConfig({
|
|
412
|
+
buildDir: 'nuxt-build',
|
|
413
|
+
})
|
|
402
414
|
```
|
|
403
415
|
|
|
404
416
|
## buildId
|
|
@@ -412,9 +424,60 @@ A unique identifier matching the build. This may contain the hash of the current
|
|
|
412
424
|
|
|
413
425
|
The builder to use for bundling the Vue part of your application.
|
|
414
426
|
|
|
415
|
-
-
|
|
427
|
+
Nuxt supports multiple builders for the client-side application. By default, Vite is used, but you can switch to webpack, Rspack, or even provide a custom builder implementation.
|
|
428
|
+
|
|
429
|
+
- **Type**: `'vite' | 'webpack' | 'rspack' | string | { bundle: (nuxt: Nuxt) => Promise<void> }`
|
|
416
430
|
- **Default:** `"@nuxt/vite-builder"`
|
|
417
431
|
|
|
432
|
+
**Using supported builders:**
|
|
433
|
+
|
|
434
|
+
```ts
|
|
435
|
+
export default defineNuxtConfig({
|
|
436
|
+
// default - uses @nuxt/vite-builder
|
|
437
|
+
// builder: 'vite',
|
|
438
|
+
|
|
439
|
+
// uses @nuxt/webpack-builder
|
|
440
|
+
// builder: 'webpack',
|
|
441
|
+
|
|
442
|
+
// uses @nuxt/rspack-builder
|
|
443
|
+
builder: 'rspack',
|
|
444
|
+
})
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
If you are using `webpack` or `rspack` you will need to make sure `@nuxt/webpack-builder` or `@nuxt/rspack-builder` is explicitly installed in your project.
|
|
448
|
+
|
|
449
|
+
**Using a custom builder object:**
|
|
450
|
+
|
|
451
|
+
You can provide a custom builder by passing an object with a `bundle` function:
|
|
452
|
+
|
|
453
|
+
```ts
|
|
454
|
+
export default defineNuxtConfig({
|
|
455
|
+
builder: {
|
|
456
|
+
async bundle (nuxt) {
|
|
457
|
+
const entry = await resolvePath(resolve(nuxt.options.appDir, 'entry'))
|
|
458
|
+
|
|
459
|
+
// Build client and server bundles
|
|
460
|
+
await buildClient(nuxt, entry)
|
|
461
|
+
if (nuxt.options.ssr) {
|
|
462
|
+
await buildServer(nuxt, entry)
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// ... it's a bit more complicated than that, of course!
|
|
466
|
+
},
|
|
467
|
+
},
|
|
468
|
+
})
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
**Creating a custom builder package:**
|
|
472
|
+
|
|
473
|
+
To create a custom builder as a separate package, it should export a `bundle` function. You can then specify the package name in your `nuxt.config.ts`:
|
|
474
|
+
|
|
475
|
+
```ts
|
|
476
|
+
export default defineNuxtConfig({
|
|
477
|
+
builder: 'my-custom-builder',
|
|
478
|
+
})
|
|
479
|
+
```
|
|
480
|
+
|
|
418
481
|
## compatibilityDate
|
|
419
482
|
|
|
420
483
|
Specify a compatibility date for your app.
|
|
@@ -442,7 +505,7 @@ Any components in the directories configured here can be used throughout your pa
|
|
|
442
505
|
}
|
|
443
506
|
```
|
|
444
507
|
|
|
445
|
-
**See**: [`app/components/` directory documentation](https://nuxt.com/docs/guide/directory-structure/app/components)
|
|
508
|
+
**See**: [`app/components/` directory documentation](https://nuxt.com/docs/4.x/guide/directory-structure/app/components)
|
|
446
509
|
|
|
447
510
|
## css
|
|
448
511
|
|
|
@@ -453,15 +516,17 @@ Nuxt will automatically guess the file type by its extension and use the appropr
|
|
|
453
516
|
- **Type**: `array`
|
|
454
517
|
|
|
455
518
|
**Example**:
|
|
456
|
-
```
|
|
457
|
-
|
|
519
|
+
```ts
|
|
520
|
+
export default defineNuxtConfig({
|
|
521
|
+
css: [
|
|
458
522
|
// Load a Node.js module directly (here it's a Sass file).
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
]
|
|
523
|
+
'bulma',
|
|
524
|
+
// CSS file in the project
|
|
525
|
+
'~/assets/css/main.css',
|
|
526
|
+
// SCSS file in the project
|
|
527
|
+
'~/assets/css/main.scss',
|
|
528
|
+
],
|
|
529
|
+
})
|
|
465
530
|
```
|
|
466
531
|
|
|
467
532
|
## debug
|
|
@@ -516,9 +581,9 @@ export default defineNuxtConfig({
|
|
|
516
581
|
devServer: {
|
|
517
582
|
https: {
|
|
518
583
|
key: './server.key',
|
|
519
|
-
cert: './server.crt'
|
|
520
|
-
}
|
|
521
|
-
}
|
|
584
|
+
cert: './server.crt',
|
|
585
|
+
},
|
|
586
|
+
},
|
|
522
587
|
})
|
|
523
588
|
```
|
|
524
589
|
|
|
@@ -532,693 +597,130 @@ Template to show a loading screen
|
|
|
532
597
|
|
|
533
598
|
Dev server listening port
|
|
534
599
|
|
|
535
|
-
- **Type**: `number`
|
|
536
|
-
- **Default:** `3000`
|
|
537
|
-
|
|
538
|
-
### `url`
|
|
539
|
-
|
|
540
|
-
Listening dev server URL.
|
|
541
|
-
|
|
542
|
-
This should not be set directly as it will always be overridden by the dev server with the full URL (for module and internal use).
|
|
543
|
-
|
|
544
|
-
- **Type**: `string`
|
|
545
|
-
- **Default:** `"http://localhost:3000"`
|
|
546
|
-
|
|
547
|
-
## devServerHandlers
|
|
548
|
-
|
|
549
|
-
Nitro development-only server handlers.
|
|
550
|
-
|
|
551
|
-
- **Type**: `array`
|
|
552
|
-
|
|
553
|
-
**See**: [Nitro server routes documentation](https://nitro.build/guide/routing)
|
|
554
|
-
|
|
555
|
-
## devtools
|
|
556
|
-
|
|
557
|
-
Enable Nuxt DevTools for development.
|
|
558
|
-
|
|
559
|
-
Breaking changes for devtools might not reflect on the version of Nuxt.
|
|
560
|
-
|
|
561
|
-
**See**: [Nuxt DevTools](https://devtools.nuxt.com/) for more information.
|
|
562
|
-
|
|
563
|
-
## dir
|
|
564
|
-
|
|
565
|
-
Customize default directory structure used by Nuxt.
|
|
566
|
-
|
|
567
|
-
It is better to stick with defaults unless needed.
|
|
568
|
-
|
|
569
|
-
### `app`
|
|
570
|
-
|
|
571
|
-
- **Type**: `string`
|
|
572
|
-
- **Default:** `"app"`
|
|
573
|
-
|
|
574
|
-
### `assets`
|
|
575
|
-
|
|
576
|
-
The assets directory (aliased as `~assets` in your build).
|
|
577
|
-
|
|
578
|
-
- **Type**: `string`
|
|
579
|
-
- **Default:** `"app/assets"`
|
|
580
|
-
|
|
581
|
-
### `layouts`
|
|
582
|
-
|
|
583
|
-
The layouts directory, each file of which will be auto-registered as a Nuxt layout.
|
|
584
|
-
|
|
585
|
-
- **Type**: `string`
|
|
586
|
-
- **Default:** `"app/layouts"`
|
|
587
|
-
|
|
588
|
-
### `middleware`
|
|
589
|
-
|
|
590
|
-
The middleware directory, each file of which will be auto-registered as a Nuxt middleware.
|
|
591
|
-
|
|
592
|
-
- **Type**: `string`
|
|
593
|
-
- **Default:** `"app/middleware"`
|
|
594
|
-
|
|
595
|
-
### `modules`
|
|
596
|
-
|
|
597
|
-
The modules directory, each file in which will be auto-registered as a Nuxt module.
|
|
598
|
-
|
|
599
|
-
- **Type**: `string`
|
|
600
|
-
- **Default:** `"modules"`
|
|
601
|
-
|
|
602
|
-
### `pages`
|
|
603
|
-
|
|
604
|
-
The directory which will be processed to auto-generate your application page routes.
|
|
605
|
-
|
|
606
|
-
- **Type**: `string`
|
|
607
|
-
- **Default:** `"app/pages"`
|
|
608
|
-
|
|
609
|
-
### `plugins`
|
|
610
|
-
|
|
611
|
-
The plugins directory, each file of which will be auto-registered as a Nuxt plugin.
|
|
612
|
-
|
|
613
|
-
- **Type**: `string`
|
|
614
|
-
- **Default:** `"app/plugins"`
|
|
615
|
-
|
|
616
|
-
### `public`
|
|
617
|
-
|
|
618
|
-
The directory containing your static files, which will be directly accessible via the Nuxt server and copied across into your `dist` folder when your app is generated.
|
|
619
|
-
|
|
620
|
-
- **Type**: `string`
|
|
621
|
-
- **Default:** `"public"`
|
|
622
|
-
|
|
623
|
-
### `shared`
|
|
624
|
-
|
|
625
|
-
The shared directory. This directory is shared between the app and the server.
|
|
626
|
-
|
|
627
|
-
- **Type**: `string`
|
|
628
|
-
- **Default:** `"shared"`
|
|
629
|
-
|
|
630
|
-
## esbuild
|
|
631
|
-
|
|
632
|
-
### `options`
|
|
633
|
-
|
|
634
|
-
Configure shared esbuild options used within Nuxt and passed to other builders, such as Vite or webpack.
|
|
635
|
-
|
|
636
|
-
#### `jsxFactory`
|
|
637
|
-
|
|
638
|
-
- **Type**: `string`
|
|
639
|
-
- **Default:** `"h"`
|
|
640
|
-
|
|
641
|
-
#### `jsxFragment`
|
|
642
|
-
|
|
643
|
-
- **Type**: `string`
|
|
644
|
-
- **Default:** `"Fragment"`
|
|
645
|
-
|
|
646
|
-
#### `target`
|
|
647
|
-
|
|
648
|
-
- **Type**: `string`
|
|
649
|
-
- **Default:** `"esnext"`
|
|
650
|
-
|
|
651
|
-
#### `tsconfigRaw`
|
|
652
|
-
|
|
653
|
-
- **Type**: `object`
|
|
654
|
-
|
|
655
|
-
## experimental
|
|
656
|
-
|
|
657
|
-
### `alwaysRunFetchOnKeyChange`
|
|
658
|
-
|
|
659
|
-
Whether to run `useFetch` when the key changes, even if it is set to `immediate: false` and it has not been triggered yet.
|
|
660
|
-
|
|
661
|
-
`useFetch` and `useAsyncData` will always run when the key changes if `immediate: true` or if it has been already triggered.
|
|
662
|
-
|
|
663
|
-
- **Type**: `boolean`
|
|
664
|
-
- **Default:** `true`
|
|
665
|
-
|
|
666
|
-
### `appManifest`
|
|
667
|
-
|
|
668
|
-
Use app manifests to respect route rules on client-side.
|
|
669
|
-
|
|
670
|
-
- **Type**: `boolean`
|
|
671
|
-
- **Default:** `true`
|
|
672
|
-
|
|
673
|
-
### `asyncContext`
|
|
674
|
-
|
|
675
|
-
Enable native async context to be accessible for nested composables
|
|
676
|
-
|
|
677
|
-
- **Type**: `boolean`
|
|
678
|
-
- **Default:** `false`
|
|
679
|
-
|
|
680
|
-
**See**: [Nuxt PR #20918](https://github.com/nuxt/nuxt/pull/20918)
|
|
681
|
-
|
|
682
|
-
### `asyncEntry`
|
|
683
|
-
|
|
684
|
-
Set to true to generate an async entry point for the Vue bundle (for module federation support).
|
|
685
|
-
|
|
686
|
-
- **Type**: `boolean`
|
|
687
|
-
- **Default:** `false`
|
|
688
|
-
|
|
689
|
-
### `browserDevtoolsTiming`
|
|
690
|
-
|
|
691
|
-
Enable timings for Nuxt application hooks in the performance panel of Chromium-based browsers.
|
|
692
|
-
|
|
693
|
-
This feature adds performance markers for Nuxt hooks, allowing you to track their execution time in the browser's Performance tab. This is particularly useful for debugging performance issues.
|
|
694
|
-
|
|
695
|
-
- **Type**: `boolean`
|
|
696
|
-
- **Default:** `false`
|
|
697
|
-
|
|
698
|
-
**Example**:
|
|
699
|
-
```ts
|
|
700
|
-
// nuxt.config.ts
|
|
701
|
-
export default defineNuxtConfig({
|
|
702
|
-
experimental: {
|
|
703
|
-
// Enable performance markers for Nuxt hooks in browser devtools
|
|
704
|
-
browserDevtoolsTiming: true
|
|
705
|
-
}
|
|
706
|
-
})
|
|
707
|
-
```
|
|
708
|
-
|
|
709
|
-
**See**: [PR #29922](https://github.com/nuxt/nuxt/pull/29922)
|
|
710
|
-
|
|
711
|
-
**See**: [Chrome DevTools Performance API](https://developer.chrome.com/docs/devtools/performance/extension#tracks)
|
|
712
|
-
|
|
713
|
-
### `buildCache`
|
|
714
|
-
|
|
715
|
-
Cache Nuxt/Nitro build artifacts based on a hash of the configuration and source files.
|
|
716
|
-
|
|
717
|
-
This only works for source files within `srcDir` and `serverDir` for the Vue/Nitro parts of your app.
|
|
718
|
-
|
|
719
|
-
- **Type**: `boolean`
|
|
720
|
-
- **Default:** `false`
|
|
721
|
-
|
|
722
|
-
### `checkOutdatedBuildInterval`
|
|
723
|
-
|
|
724
|
-
Set the time interval (in ms) to check for new builds. Disabled when `experimental.appManifest` is `false`.
|
|
725
|
-
|
|
726
|
-
Set to `false` to disable.
|
|
727
|
-
|
|
728
|
-
- **Type**: `number`
|
|
729
|
-
- **Default:** `3600000`
|
|
730
|
-
|
|
731
|
-
### `clientFallback`
|
|
732
|
-
|
|
733
|
-
Whether to enable the experimental `<NuxtClientFallback>` component for rendering content on the client if there's an error in SSR.
|
|
734
|
-
|
|
735
|
-
- **Type**: `boolean`
|
|
736
|
-
- **Default:** `false`
|
|
737
|
-
|
|
738
|
-
### `clientNodeCompat`
|
|
739
|
-
|
|
740
|
-
Automatically polyfill Node.js imports in the client build using `unenv`.
|
|
741
|
-
|
|
742
|
-
- **Type**: `boolean`
|
|
743
|
-
- **Default:** `false`
|
|
744
|
-
|
|
745
|
-
**See**: [unenv](https://github.com/unjs/unenv)
|
|
746
|
-
|
|
747
|
-
**Note:** To make globals like `Buffer` work in the browser, you need to manually inject them.
|
|
748
|
-
|
|
749
|
-
```ts
|
|
750
|
-
import { Buffer } from 'node:buffer'
|
|
751
|
-
|
|
752
|
-
globalThis.Buffer = globalThis.Buffer || Buffer
|
|
753
|
-
```
|
|
754
|
-
|
|
755
|
-
### `compileTemplate`
|
|
756
|
-
|
|
757
|
-
Whether to use `lodash.template` to compile Nuxt templates.
|
|
758
|
-
|
|
759
|
-
This flag will be removed with the release of v4 and exists only for advance testing within Nuxt v3.12+ or in [the nightly release channel](/docs/guide/going-further/nightly-release-channel).
|
|
760
|
-
|
|
761
|
-
- **Type**: `boolean`
|
|
762
|
-
- **Default:** `true`
|
|
763
|
-
|
|
764
|
-
### `componentIslands`
|
|
765
|
-
|
|
766
|
-
Experimental component islands support with `<NuxtIsland>` and `.island.vue` files.
|
|
767
|
-
|
|
768
|
-
By default it is set to 'auto', which means it will be enabled only when there are islands, server components or server pages in your app.
|
|
769
|
-
|
|
770
|
-
- **Type**: `string`
|
|
771
|
-
- **Default:** `"auto"`
|
|
772
|
-
|
|
773
|
-
### `configSchema`
|
|
774
|
-
|
|
775
|
-
Config schema support
|
|
776
|
-
|
|
777
|
-
- **Type**: `boolean`
|
|
778
|
-
- **Default:** `true`
|
|
779
|
-
|
|
780
|
-
**See**: [Nuxt Issue #15592](https://github.com/nuxt/nuxt/issues/15592)
|
|
781
|
-
|
|
782
|
-
### `cookieStore`
|
|
783
|
-
|
|
784
|
-
Enables CookieStore support to listen for cookie updates (if supported by the browser) and refresh `useCookie` ref values.
|
|
785
|
-
|
|
786
|
-
- **Type**: `boolean`
|
|
787
|
-
- **Default:** `true`
|
|
788
|
-
|
|
789
|
-
**See**: [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore)
|
|
790
|
-
|
|
791
|
-
### `crossOriginPrefetch`
|
|
792
|
-
|
|
793
|
-
Enable cross-origin prefetch using the Speculation Rules API.
|
|
794
|
-
|
|
795
|
-
- **Type**: `boolean`
|
|
796
|
-
- **Default:** `false`
|
|
797
|
-
|
|
798
|
-
### `debugModuleMutation`
|
|
799
|
-
|
|
800
|
-
Record mutations to `nuxt.options` in module context, helping to debug configuration changes made by modules during the Nuxt initialization phase.
|
|
801
|
-
|
|
802
|
-
When enabled, Nuxt will track which modules modify configuration options, making it easier to trace unexpected configuration changes.
|
|
803
|
-
|
|
804
|
-
- **Type**: `boolean`
|
|
805
|
-
- **Default:** `false`
|
|
806
|
-
|
|
807
|
-
**Example**:
|
|
808
|
-
```ts
|
|
809
|
-
// nuxt.config.ts
|
|
810
|
-
export default defineNuxtConfig({
|
|
811
|
-
experimental: {
|
|
812
|
-
// Enable tracking of config mutations by modules
|
|
813
|
-
debugModuleMutation: true
|
|
814
|
-
}
|
|
815
|
-
})
|
|
816
|
-
```
|
|
817
|
-
|
|
818
|
-
**See**: [PR #30555](https://github.com/nuxt/nuxt/pull/30555)
|
|
819
|
-
|
|
820
|
-
### `decorators`
|
|
821
|
-
|
|
822
|
-
Enable the use of experimental decorators in Nuxt and Nitro.
|
|
823
|
-
|
|
824
|
-
- **Type**: `boolean`
|
|
825
|
-
- **Default:** `false`
|
|
826
|
-
|
|
827
|
-
**See**: https://github.com/tc39/proposal-decorators
|
|
828
|
-
|
|
829
|
-
### `defaults`
|
|
830
|
-
|
|
831
|
-
This allows specifying the default options for core Nuxt components and composables.
|
|
832
|
-
|
|
833
|
-
These options will likely be moved elsewhere in the future, such as into `app.config` or into the `app/` directory.
|
|
834
|
-
|
|
835
|
-
#### `nuxtLink`
|
|
836
|
-
|
|
837
|
-
##### `componentName`
|
|
838
|
-
|
|
839
|
-
- **Type**: `string`
|
|
840
|
-
- **Default:** `"NuxtLink"`
|
|
841
|
-
|
|
842
|
-
##### `prefetch`
|
|
843
|
-
|
|
844
|
-
- **Type**: `boolean`
|
|
845
|
-
- **Default:** `true`
|
|
846
|
-
|
|
847
|
-
##### `prefetchOn`
|
|
848
|
-
|
|
849
|
-
###### `visibility`
|
|
850
|
-
|
|
851
|
-
- **Type**: `boolean`
|
|
852
|
-
- **Default:** `true`
|
|
853
|
-
|
|
854
|
-
#### `useAsyncData`
|
|
855
|
-
|
|
856
|
-
Options that apply to `useAsyncData` (and also therefore `useFetch`)
|
|
857
|
-
|
|
858
|
-
##### `deep`
|
|
859
|
-
|
|
860
|
-
- **Type**: `boolean`
|
|
861
|
-
- **Default:** `true`
|
|
862
|
-
|
|
863
|
-
##### `errorValue`
|
|
864
|
-
|
|
865
|
-
- **Type**: `string`
|
|
866
|
-
- **Default:** `"null"`
|
|
867
|
-
|
|
868
|
-
##### `value`
|
|
869
|
-
|
|
870
|
-
- **Type**: `string`
|
|
871
|
-
- **Default:** `"null"`
|
|
872
|
-
|
|
873
|
-
#### `useFetch`
|
|
874
|
-
|
|
875
|
-
### `emitRouteChunkError`
|
|
876
|
-
|
|
877
|
-
Emit `app:chunkError` hook when there is an error loading vite/webpack chunks.
|
|
878
|
-
|
|
879
|
-
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`).
|
|
880
|
-
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).
|
|
881
|
-
You can disable automatic handling by setting this to `false`, or handle chunk errors manually by setting it to `manual`.
|
|
882
|
-
|
|
883
|
-
- **Type**: `string`
|
|
884
|
-
- **Default:** `"automatic"`
|
|
885
|
-
|
|
886
|
-
**See**: [Nuxt PR #19038](https://github.com/nuxt/nuxt/pull/19038)
|
|
887
|
-
|
|
888
|
-
### `enforceModuleCompatibility`
|
|
889
|
-
|
|
890
|
-
Whether Nuxt should stop if a Nuxt module is incompatible.
|
|
891
|
-
|
|
892
|
-
- **Type**: `boolean`
|
|
893
|
-
- **Default:** `false`
|
|
894
|
-
|
|
895
|
-
### `externalVue`
|
|
896
|
-
|
|
897
|
-
Externalize `vue`, `@vue/*` and `vue-router` when building.
|
|
898
|
-
|
|
899
|
-
- **Type**: `boolean`
|
|
900
|
-
- **Default:** `true`
|
|
901
|
-
|
|
902
|
-
**See**: [Nuxt Issue #13632](https://github.com/nuxt/nuxt/issues/13632)
|
|
903
|
-
|
|
904
|
-
### `extraPageMetaExtractionKeys`
|
|
905
|
-
|
|
906
|
-
Configure additional keys to extract from the page metadata when using `scanPageMeta`.
|
|
907
|
-
|
|
908
|
-
This allows modules to access additional metadata from the page metadata. It's recommended to augment the NuxtPage types with your keys.
|
|
909
|
-
|
|
910
|
-
- **Type**: `array`
|
|
911
|
-
|
|
912
|
-
### `granularCachedData`
|
|
913
|
-
|
|
914
|
-
Whether to call and use the result from `getCachedData` on manual refresh for `useAsyncData` and `useFetch`.
|
|
915
|
-
|
|
916
|
-
- **Type**: `boolean`
|
|
917
|
-
- **Default:** `false`
|
|
918
|
-
|
|
919
|
-
### `headNext`
|
|
920
|
-
|
|
921
|
-
Use new experimental head optimisations:
|
|
922
|
-
|
|
923
|
-
- Add the capo.js head plugin in order to render tags in of the head in a more performant way. - Uses the hash hydration plugin to reduce initial hydration
|
|
924
|
-
|
|
925
|
-
- **Type**: `boolean`
|
|
926
|
-
- **Default:** `true`
|
|
927
|
-
|
|
928
|
-
**See**: [Nuxt Discussion #22632](https://github.com/nuxt/nuxt/discussions/22632)
|
|
929
|
-
|
|
930
|
-
### `inlineRouteRules`
|
|
931
|
-
|
|
932
|
-
Allow defining `routeRules` directly within your `~/pages` directory using `defineRouteRules`.
|
|
933
|
-
|
|
934
|
-
Rules are converted (based on the path) and applied for server requests. For example, a rule defined in `~/pages/foo/bar.vue` will be applied to `/foo/bar` requests. A rule in `~/pages/foo/[id].vue` will be applied to `/foo/**` requests.
|
|
935
|
-
For more control, such as if you are using a custom `path` or `alias` set in the page's `definePageMeta`, you should set `routeRules` directly within your `nuxt.config`.
|
|
936
|
-
|
|
937
|
-
- **Type**: `boolean`
|
|
938
|
-
- **Default:** `false`
|
|
939
|
-
|
|
940
|
-
### `lazyHydration`
|
|
941
|
-
|
|
942
|
-
Enable automatic configuration of hydration strategies for `<Lazy>` components.
|
|
943
|
-
|
|
944
|
-
This feature intelligently determines when to hydrate lazy components based on visibility, idle time, or other triggers, improving performance by deferring hydration of components until they're needed.
|
|
945
|
-
|
|
946
|
-
- **Type**: `boolean`
|
|
947
|
-
- **Default:** `true`
|
|
948
|
-
|
|
949
|
-
**Example**:
|
|
950
|
-
```ts
|
|
951
|
-
// nuxt.config.ts
|
|
952
|
-
export default defineNuxtConfig({
|
|
953
|
-
experimental: {
|
|
954
|
-
lazyHydration: true // Enable smart hydration strategies for Lazy components
|
|
955
|
-
}
|
|
956
|
-
})
|
|
957
|
-
|
|
958
|
-
// In your Vue components
|
|
959
|
-
<template>
|
|
960
|
-
<Lazy>
|
|
961
|
-
<ExpensiveComponent />
|
|
962
|
-
</Lazy>
|
|
963
|
-
</template>
|
|
964
|
-
```
|
|
965
|
-
|
|
966
|
-
**See**: [PR #26468](https://github.com/nuxt/nuxt/pull/26468)
|
|
967
|
-
|
|
968
|
-
### `localLayerAliases`
|
|
969
|
-
|
|
970
|
-
Resolve `~`, `~~`, `@` and `@@` aliases located within layers with respect to their layer source and root directories.
|
|
971
|
-
|
|
972
|
-
- **Type**: `boolean`
|
|
973
|
-
- **Default:** `true`
|
|
974
|
-
|
|
975
|
-
### `navigationRepaint`
|
|
976
|
-
|
|
977
|
-
Wait for a single animation frame before navigation, which gives an opportunity for the browser to repaint, acknowledging user interaction.
|
|
978
|
-
|
|
979
|
-
It can reduce INP when navigating on prerendered routes.
|
|
980
|
-
|
|
981
|
-
- **Type**: `boolean`
|
|
982
|
-
- **Default:** `true`
|
|
983
|
-
|
|
984
|
-
### `noVueServer`
|
|
985
|
-
|
|
986
|
-
Disable vue server renderer endpoint within nitro.
|
|
987
|
-
|
|
988
|
-
- **Type**: `boolean`
|
|
989
|
-
- **Default:** `false`
|
|
990
|
-
|
|
991
|
-
### `normalizeComponentNames`
|
|
992
|
-
|
|
993
|
-
Ensure that auto-generated Vue component names match the full component name you would use to auto-import the component.
|
|
994
|
-
|
|
995
|
-
- **Type**: `boolean`
|
|
996
|
-
- **Default:** `false`
|
|
997
|
-
|
|
998
|
-
### `parseErrorData`
|
|
999
|
-
|
|
1000
|
-
Whether to parse `error.data` when rendering a server error page.
|
|
1001
|
-
|
|
1002
|
-
- **Type**: `boolean`
|
|
1003
|
-
- **Default:** `false`
|
|
1004
|
-
|
|
1005
|
-
### `payloadExtraction`
|
|
1006
|
-
|
|
1007
|
-
When this option is enabled (by default) payload of pages that are prerendered are extracted
|
|
1008
|
-
|
|
1009
|
-
- **Type**: `boolean`
|
|
1010
|
-
- **Default:** `true`
|
|
1011
|
-
|
|
1012
|
-
### `pendingWhenIdle`
|
|
1013
|
-
|
|
1014
|
-
For `useAsyncData` and `useFetch`, whether `pending` should be `true` when data has not yet started to be fetched.
|
|
1015
|
-
|
|
1016
|
-
- **Type**: `boolean`
|
|
1017
|
-
- **Default:** `true`
|
|
1018
|
-
|
|
1019
|
-
### `polyfillVueUseHead`
|
|
1020
|
-
|
|
1021
|
-
Whether or not to add a compatibility layer for modules, plugins or user code relying on the old `@vueuse/head` API.
|
|
1022
|
-
|
|
1023
|
-
This is disabled to reduce the client-side bundle by ~0.5kb.
|
|
1024
|
-
|
|
1025
|
-
- **Type**: `boolean`
|
|
1026
|
-
- **Default:** `false`
|
|
1027
|
-
|
|
1028
|
-
### `purgeCachedData`
|
|
1029
|
-
|
|
1030
|
-
Whether to clean up Nuxt static and asyncData caches on route navigation.
|
|
1031
|
-
|
|
1032
|
-
Nuxt will automatically purge cached data from `useAsyncData` and `nuxtApp.static.data`. This helps prevent memory leaks and ensures fresh data is loaded when needed, but it is possible to disable it.
|
|
1033
|
-
|
|
1034
|
-
- **Type**: `boolean`
|
|
1035
|
-
- **Default:** `true`
|
|
1036
|
-
|
|
1037
|
-
**Example**:
|
|
1038
|
-
```ts
|
|
1039
|
-
// nuxt.config.ts
|
|
1040
|
-
export default defineNuxtConfig({
|
|
1041
|
-
experimental: {
|
|
1042
|
-
// Disable automatic cache cleanup (default is true)
|
|
1043
|
-
purgeCachedData: false
|
|
1044
|
-
}
|
|
1045
|
-
})
|
|
1046
|
-
```
|
|
1047
|
-
|
|
1048
|
-
**See**: [PR #31379](https://github.com/nuxt/nuxt/pull/31379)
|
|
1049
|
-
|
|
1050
|
-
### `relativeWatchPaths`
|
|
1051
|
-
|
|
1052
|
-
Whether to provide relative paths in the `builder:watch` hook.
|
|
1053
|
-
|
|
1054
|
-
This flag will be removed with the release of v4 and exists only for advance testing within Nuxt v3.12+ or in [the nightly release channel](/docs/guide/going-further/nightly-release-channel).
|
|
1055
|
-
|
|
1056
|
-
- **Type**: `boolean`
|
|
1057
|
-
- **Default:** `true`
|
|
1058
|
-
|
|
1059
|
-
### `renderJsonPayloads`
|
|
1060
|
-
|
|
1061
|
-
Render JSON payloads with support for revivifying complex types.
|
|
1062
|
-
|
|
1063
|
-
- **Type**: `boolean`
|
|
1064
|
-
- **Default:** `true`
|
|
1065
|
-
|
|
1066
|
-
### `resetAsyncDataToUndefined`
|
|
1067
|
-
|
|
1068
|
-
Whether `clear` and `clearNuxtData` should reset async data to its _default_ value or update it to `null`/`undefined`.
|
|
1069
|
-
|
|
1070
|
-
- **Type**: `boolean`
|
|
1071
|
-
- **Default:** `true`
|
|
1072
|
-
|
|
1073
|
-
### `respectNoSSRHeader`
|
|
1074
|
-
|
|
1075
|
-
Allow disabling Nuxt SSR responses by setting the `x-nuxt-no-ssr` header.
|
|
1076
|
-
|
|
1077
|
-
- **Type**: `boolean`
|
|
1078
|
-
- **Default:** `false`
|
|
600
|
+
- **Type**: `number`
|
|
601
|
+
- **Default:** `3000`
|
|
1079
602
|
|
|
1080
|
-
### `
|
|
603
|
+
### `url`
|
|
1081
604
|
|
|
1082
|
-
|
|
605
|
+
Listening dev server URL.
|
|
1083
606
|
|
|
1084
|
-
|
|
1085
|
-
Consider carefully before enabling this as it can cause unexpected behavior, and consider providing explicit keys to `useState` as auto-generated keys may not match across builds.
|
|
607
|
+
This should not be set directly as it will always be overridden by the dev server with the full URL (for module and internal use).
|
|
1086
608
|
|
|
1087
|
-
- **Type**: `
|
|
1088
|
-
- **Default:** `
|
|
609
|
+
- **Type**: `string`
|
|
610
|
+
- **Default:** `"http://localhost:3000"`
|
|
1089
611
|
|
|
1090
|
-
|
|
612
|
+
## devServerHandlers
|
|
1091
613
|
|
|
1092
|
-
|
|
614
|
+
Nitro development-only server handlers.
|
|
1093
615
|
|
|
1094
|
-
|
|
616
|
+
- **Type**: `array`
|
|
1095
617
|
|
|
1096
|
-
|
|
1097
|
-
- **Default:** `true`
|
|
618
|
+
**See**: [Nitro server routes documentation](https://nitro.build/guide/routing)
|
|
1098
619
|
|
|
1099
|
-
|
|
620
|
+
## devtools
|
|
1100
621
|
|
|
1101
|
-
|
|
622
|
+
Enable Nuxt DevTools for development.
|
|
1102
623
|
|
|
1103
|
-
|
|
624
|
+
Breaking changes for devtools might not reflect on the version of Nuxt.
|
|
1104
625
|
|
|
1105
|
-
|
|
626
|
+
**See**: [Nuxt DevTools](https://devtools.nuxt.com/) for more information.
|
|
1106
627
|
|
|
1107
|
-
|
|
1108
|
-
- **Default:** `false`
|
|
628
|
+
## dir
|
|
1109
629
|
|
|
1110
|
-
|
|
1111
|
-
```ts
|
|
1112
|
-
// This would be unsafe in a dynamic page (e.g. `[slug].vue`) because the route slug makes a difference
|
|
1113
|
-
// to the data fetched, but Nuxt can't know that because it's not reflected in the key.
|
|
1114
|
-
const route = useRoute()
|
|
1115
|
-
const { data } = await useAsyncData(async () => {
|
|
1116
|
-
return await $fetch(`/api/my-page/${route.params.slug}`)
|
|
1117
|
-
})
|
|
1118
|
-
// Instead, you should use a key that uniquely identifies the data fetched.
|
|
1119
|
-
const { data } = await useAsyncData(route.params.slug, async () => {
|
|
1120
|
-
return await $fetch(`/api/my-page/${route.params.slug}`)
|
|
1121
|
-
})
|
|
1122
|
-
```
|
|
630
|
+
Customize default directory structure used by Nuxt.
|
|
1123
631
|
|
|
1124
|
-
|
|
632
|
+
It is better to stick with defaults unless needed.
|
|
1125
633
|
|
|
1126
|
-
|
|
634
|
+
### `app`
|
|
1127
635
|
|
|
1128
636
|
- **Type**: `string`
|
|
1129
|
-
- **Default:** `"
|
|
637
|
+
- **Default:** `"app"`
|
|
638
|
+
|
|
639
|
+
### `assets`
|
|
1130
640
|
|
|
1131
|
-
|
|
641
|
+
The assets directory (aliased as `~assets` in your build).
|
|
1132
642
|
|
|
1133
|
-
|
|
643
|
+
- **Type**: `string`
|
|
644
|
+
- **Default:** `"app/assets"`
|
|
1134
645
|
|
|
1135
|
-
|
|
646
|
+
### `layouts`
|
|
1136
647
|
|
|
1137
|
-
|
|
648
|
+
The layouts directory, each file of which will be auto-registered as a Nuxt layout.
|
|
1138
649
|
|
|
1139
|
-
- **Type**: `
|
|
1140
|
-
- **Default:** `
|
|
650
|
+
- **Type**: `string`
|
|
651
|
+
- **Default:** `"app/layouts"`
|
|
1141
652
|
|
|
1142
|
-
|
|
1143
|
-
```ts
|
|
1144
|
-
// nuxt.config.ts
|
|
1145
|
-
export default defineNuxtConfig({
|
|
1146
|
-
experimental: {
|
|
1147
|
-
// Disable template import resolution from module path
|
|
1148
|
-
templateImportResolution: false
|
|
1149
|
-
}
|
|
1150
|
-
})
|
|
1151
|
-
```
|
|
653
|
+
### `middleware`
|
|
1152
654
|
|
|
1153
|
-
|
|
655
|
+
The middleware directory, each file of which will be auto-registered as a Nuxt middleware.
|
|
1154
656
|
|
|
1155
|
-
|
|
657
|
+
- **Type**: `string`
|
|
658
|
+
- **Default:** `"app/middleware"`
|
|
1156
659
|
|
|
1157
|
-
|
|
660
|
+
### `modules`
|
|
1158
661
|
|
|
1159
|
-
|
|
662
|
+
The modules directory, each file in which will be auto-registered as a Nuxt module.
|
|
1160
663
|
|
|
1161
|
-
- **Type**: `
|
|
1162
|
-
- **Default:** `
|
|
664
|
+
- **Type**: `string`
|
|
665
|
+
- **Default:** `"modules"`
|
|
1163
666
|
|
|
1164
|
-
### `
|
|
667
|
+
### `pages`
|
|
1165
668
|
|
|
1166
|
-
|
|
669
|
+
The directory which will be processed to auto-generate your application page routes.
|
|
1167
670
|
|
|
1168
|
-
|
|
671
|
+
- **Type**: `string`
|
|
672
|
+
- **Default:** `"app/pages"`
|
|
1169
673
|
|
|
1170
|
-
|
|
1171
|
-
- **Default:** `true`
|
|
674
|
+
### `plugins`
|
|
1172
675
|
|
|
1173
|
-
|
|
676
|
+
The plugins directory, each file of which will be auto-registered as a Nuxt plugin.
|
|
1174
677
|
|
|
1175
|
-
|
|
678
|
+
- **Type**: `string`
|
|
679
|
+
- **Default:** `"app/plugins"`
|
|
1176
680
|
|
|
1177
|
-
|
|
1178
|
-
- **Default:** `true`
|
|
681
|
+
### `public`
|
|
1179
682
|
|
|
1180
|
-
|
|
683
|
+
The directory containing your static files, which will be directly accessible via the Nuxt server and copied across into your `dist` folder when your app is generated.
|
|
1181
684
|
|
|
1182
|
-
|
|
685
|
+
- **Type**: `string`
|
|
686
|
+
- **Default:** `"public"`
|
|
1183
687
|
|
|
1184
|
-
|
|
688
|
+
### `shared`
|
|
1185
689
|
|
|
1186
|
-
|
|
1187
|
-
- **Default:** `false`
|
|
690
|
+
The shared directory. This directory is shared between the app and the server.
|
|
1188
691
|
|
|
1189
|
-
|
|
692
|
+
- **Type**: `string`
|
|
693
|
+
- **Default:** `"shared"`
|
|
1190
694
|
|
|
1191
|
-
|
|
695
|
+
## esbuild
|
|
1192
696
|
|
|
1193
|
-
|
|
1194
|
-
- **Default:** `false`
|
|
697
|
+
### `options`
|
|
1195
698
|
|
|
1196
|
-
|
|
699
|
+
Configure shared esbuild options used within Nuxt and passed to other builders, such as Vite or webpack.
|
|
1197
700
|
|
|
1198
|
-
|
|
701
|
+
#### `jsxFactory`
|
|
1199
702
|
|
|
1200
|
-
|
|
703
|
+
- **Type**: `string`
|
|
704
|
+
- **Default:** `"h"`
|
|
1201
705
|
|
|
1202
|
-
|
|
1203
|
-
You can set this instead to `parcel` to use `@parcel/watcher`, which may improve performance in large projects or on Windows platforms.
|
|
1204
|
-
You can also set this to `chokidar` to watch all files in your source directory.
|
|
706
|
+
#### `jsxFragment`
|
|
1205
707
|
|
|
1206
708
|
- **Type**: `string`
|
|
1207
|
-
- **Default:** `"
|
|
709
|
+
- **Default:** `"Fragment"`
|
|
1208
710
|
|
|
1209
|
-
|
|
711
|
+
#### `target`
|
|
1210
712
|
|
|
1211
|
-
**
|
|
713
|
+
- **Type**: `string`
|
|
714
|
+
- **Default:** `"esnext"`
|
|
1212
715
|
|
|
1213
|
-
|
|
716
|
+
#### `tsconfigRaw`
|
|
1214
717
|
|
|
1215
|
-
|
|
718
|
+
- **Type**: `object`
|
|
1216
719
|
|
|
1217
|
-
|
|
1218
|
-
- **Default:** `false`
|
|
720
|
+
## experimental
|
|
1219
721
|
|
|
1220
|
-
::
|
|
1221
|
-
|
|
722
|
+
::read-more{to="/docs/4.x/guide/going-further/experimental-features"}
|
|
723
|
+
Learn more about Nuxt's experimental features.
|
|
1222
724
|
::
|
|
1223
725
|
|
|
1224
726
|
## extends
|
|
@@ -1251,65 +753,15 @@ The extensions that should be resolved by the Nuxt resolver.
|
|
|
1251
753
|
|
|
1252
754
|
## features
|
|
1253
755
|
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
Stream server logs to the client as you are developing. These logs can be handled in the `dev:ssr-logs` hook.
|
|
1259
|
-
|
|
1260
|
-
If set to `silent`, the logs will not be printed to the browser console.
|
|
1261
|
-
|
|
1262
|
-
- **Type**: `boolean`
|
|
1263
|
-
- **Default:** `false`
|
|
1264
|
-
|
|
1265
|
-
### `inlineStyles`
|
|
1266
|
-
|
|
1267
|
-
Inline styles when rendering HTML (currently vite only).
|
|
1268
|
-
|
|
1269
|
-
You can also pass a function that receives the path of a Vue component and returns a boolean indicating whether to inline the styles for that component.
|
|
1270
|
-
|
|
1271
|
-
- **Type**: `boolean`
|
|
1272
|
-
- **Default:** `(id) => id.includes('.vue')`
|
|
1273
|
-
|
|
1274
|
-
### `noScripts`
|
|
1275
|
-
|
|
1276
|
-
Turn off rendering of Nuxt scripts and JS resource hints. You can also disable scripts more granularly within `routeRules`.
|
|
1277
|
-
|
|
1278
|
-
If set to 'production' or `true`, JS will be disabled in production mode only.
|
|
1279
|
-
|
|
1280
|
-
- **Type**: `boolean`
|
|
1281
|
-
- **Default:** `false`
|
|
756
|
+
::read-more{to="/docs/4.x/guide/going-further/features#features"}
|
|
757
|
+
Learn more about Nuxt's opt-in features.
|
|
758
|
+
::
|
|
1282
759
|
|
|
1283
760
|
## future
|
|
1284
761
|
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
This is used for enabling early access to Nuxt features or flags.
|
|
1290
|
-
|
|
1291
|
-
It is not configurable yet in Nuxt 4, but once we begin merging breaking changes for v5, it will be possible to enable it.
|
|
1292
|
-
|
|
1293
|
-
### `multiApp`
|
|
1294
|
-
|
|
1295
|
-
This enables early access to the experimental multi-app support.
|
|
1296
|
-
|
|
1297
|
-
- **Type**: `boolean`
|
|
1298
|
-
- **Default:** `false`
|
|
1299
|
-
|
|
1300
|
-
**See**: [Nuxt Issue #21635](https://github.com/nuxt/nuxt/issues/21635)
|
|
1301
|
-
|
|
1302
|
-
### `typescriptBundlerResolution`
|
|
1303
|
-
|
|
1304
|
-
This enables 'Bundler' module resolution mode for TypeScript, which is the recommended setting for frameworks like Nuxt and Vite.
|
|
1305
|
-
|
|
1306
|
-
It improves type support when using modern libraries with `exports`.
|
|
1307
|
-
You can set it to false to use the legacy 'Node' mode, which is the default for TypeScript.
|
|
1308
|
-
|
|
1309
|
-
- **Type**: `boolean`
|
|
1310
|
-
- **Default:** `true`
|
|
1311
|
-
|
|
1312
|
-
**See**: [TypeScript PR implementing `bundler` module resolution](https://github.com/microsoft/TypeScript/pull/51669)
|
|
762
|
+
::read-more{to="/docs/4.x/guide/going-further/features#features"}
|
|
763
|
+
Learn more about opting-in to new features that will become default in a future (possibly major) version of the framework.
|
|
764
|
+
::
|
|
1313
765
|
|
|
1314
766
|
## hooks
|
|
1315
767
|
|
|
@@ -1319,22 +771,23 @@ Internally, hooks follow a naming pattern using colons (e.g., build:done).
|
|
|
1319
771
|
For ease of configuration, you can also structure them as an hierarchical object in `nuxt.config` (as below).
|
|
1320
772
|
|
|
1321
773
|
**Example**:
|
|
1322
|
-
```
|
|
774
|
+
```ts
|
|
1323
775
|
import fs from 'node:fs'
|
|
1324
776
|
import path from 'node:path'
|
|
1325
|
-
|
|
777
|
+
|
|
778
|
+
export default defineNuxtConfig({
|
|
1326
779
|
hooks: {
|
|
1327
780
|
build: {
|
|
1328
|
-
done(builder) {
|
|
781
|
+
done (builder) {
|
|
1329
782
|
const extraFilePath = path.join(
|
|
1330
783
|
builder.nuxt.options.buildDir,
|
|
1331
|
-
'extra-file'
|
|
784
|
+
'extra-file',
|
|
1332
785
|
)
|
|
1333
786
|
fs.writeFileSync(extraFilePath, 'Something extra')
|
|
1334
|
-
}
|
|
1335
|
-
}
|
|
1336
|
-
}
|
|
1337
|
-
}
|
|
787
|
+
},
|
|
788
|
+
},
|
|
789
|
+
},
|
|
790
|
+
})
|
|
1338
791
|
```
|
|
1339
792
|
|
|
1340
793
|
## ignore
|
|
@@ -1363,10 +816,12 @@ Pass options directly to `node-ignore` (which is used by Nuxt to ignore files).
|
|
|
1363
816
|
**See**: [node-ignore](https://github.com/kaelzhang/node-ignore)
|
|
1364
817
|
|
|
1365
818
|
**Example**:
|
|
1366
|
-
```
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
819
|
+
```ts
|
|
820
|
+
export default defineNuxtConfig({
|
|
821
|
+
ignoreOptions: {
|
|
822
|
+
ignorecase: false,
|
|
823
|
+
},
|
|
824
|
+
})
|
|
1370
825
|
```
|
|
1371
826
|
|
|
1372
827
|
## ignorePrefix
|
|
@@ -1380,7 +835,7 @@ Any file in `app/pages/`, `app/layouts/`, `app/middleware/`, and `public/` direc
|
|
|
1380
835
|
|
|
1381
836
|
Configure how Nuxt auto-imports composables into your application.
|
|
1382
837
|
|
|
1383
|
-
**See**: [Nuxt documentation](https://nuxt.com/docs/guide/directory-structure/app/composables)
|
|
838
|
+
**See**: [Nuxt documentation](https://nuxt.com/docs/4.x/guide/directory-structure/app/composables)
|
|
1384
839
|
|
|
1385
840
|
### `dirs`
|
|
1386
841
|
|
|
@@ -1389,11 +844,13 @@ An array of custom directories that will be auto-imported. Note that this option
|
|
|
1389
844
|
- **Type**: `array`
|
|
1390
845
|
|
|
1391
846
|
**Example**:
|
|
1392
|
-
```
|
|
1393
|
-
|
|
847
|
+
```ts
|
|
848
|
+
export default defineNuxtConfig({
|
|
849
|
+
imports: {
|
|
1394
850
|
// Auto-import pinia stores defined in `~/stores`
|
|
1395
|
-
|
|
1396
|
-
}
|
|
851
|
+
dirs: ['stores'],
|
|
852
|
+
},
|
|
853
|
+
})
|
|
1397
854
|
```
|
|
1398
855
|
|
|
1399
856
|
### `global`
|
|
@@ -1432,17 +889,19 @@ directory are executed, and they load in alphabetical order.
|
|
|
1432
889
|
::
|
|
1433
890
|
|
|
1434
891
|
**Example**:
|
|
1435
|
-
```
|
|
1436
|
-
|
|
892
|
+
```ts
|
|
893
|
+
export default defineNuxtConfig({
|
|
894
|
+
modules: [
|
|
1437
895
|
// Using package name
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
]
|
|
896
|
+
'@nuxt/scripts',
|
|
897
|
+
// Relative to your project srcDir
|
|
898
|
+
'~/custom-modules/awesome.js',
|
|
899
|
+
// Providing options
|
|
900
|
+
['@nuxtjs/google-analytics', { ua: 'X1234567' }],
|
|
901
|
+
// Inline definition
|
|
902
|
+
function () {},
|
|
903
|
+
],
|
|
904
|
+
})
|
|
1446
905
|
```
|
|
1447
906
|
|
|
1448
907
|
## modulesDir
|
|
@@ -1461,10 +920,10 @@ Setting this field may be necessary if your project is organized as a yarn works
|
|
|
1461
920
|
```
|
|
1462
921
|
|
|
1463
922
|
**Example**:
|
|
1464
|
-
```
|
|
1465
|
-
export default {
|
|
1466
|
-
modulesDir: ['../../node_modules']
|
|
1467
|
-
}
|
|
923
|
+
```ts
|
|
924
|
+
export default defineNuxtConfig({
|
|
925
|
+
modulesDir: ['../../node_modules'],
|
|
926
|
+
})
|
|
1468
927
|
```
|
|
1469
928
|
|
|
1470
929
|
## nitro
|
|
@@ -1600,8 +1059,17 @@ Tree shake code from specific builds.
|
|
|
1600
1059
|
Tree shake composables from the server or client builds.
|
|
1601
1060
|
|
|
1602
1061
|
**Example**:
|
|
1603
|
-
```
|
|
1604
|
-
|
|
1062
|
+
```ts
|
|
1063
|
+
export default defineNuxtConfig({
|
|
1064
|
+
optimization: {
|
|
1065
|
+
treeShake: {
|
|
1066
|
+
composables: {
|
|
1067
|
+
client: { vue: ['onMounted'] },
|
|
1068
|
+
server: { vue: ['onServerPrefetch'] },
|
|
1069
|
+
},
|
|
1070
|
+
},
|
|
1071
|
+
},
|
|
1072
|
+
})
|
|
1605
1073
|
```
|
|
1606
1074
|
|
|
1607
1075
|
##### `client`
|
|
@@ -1655,10 +1123,12 @@ Whether to use the vue-router integration in Nuxt 3. If you do not provide a val
|
|
|
1655
1123
|
Additionally, you can provide a glob pattern or an array of patterns to scan only certain files for pages.
|
|
1656
1124
|
|
|
1657
1125
|
**Example**:
|
|
1658
|
-
```
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1126
|
+
```ts
|
|
1127
|
+
export default defineNuxtConfig({
|
|
1128
|
+
pages: {
|
|
1129
|
+
pattern: ['**/*/*.vue', '!**/*.spec.*'],
|
|
1130
|
+
},
|
|
1131
|
+
})
|
|
1662
1132
|
```
|
|
1663
1133
|
|
|
1664
1134
|
## plugins
|
|
@@ -1676,18 +1146,20 @@ and these plugins do not need to be listed in `nuxt.config` unless you
|
|
|
1676
1146
|
need to customize their order. All plugins are deduplicated by their src path.
|
|
1677
1147
|
::
|
|
1678
1148
|
|
|
1679
|
-
**See**: [`app/plugins/` directory documentation](https://nuxt.com/docs/guide/directory-structure/plugins)
|
|
1149
|
+
**See**: [`app/plugins/` directory documentation](https://nuxt.com/docs/4.x/guide/directory-structure/plugins)
|
|
1680
1150
|
|
|
1681
1151
|
**Example**:
|
|
1682
|
-
```
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1152
|
+
```ts
|
|
1153
|
+
export default defineNuxtConfig({
|
|
1154
|
+
plugins: [
|
|
1155
|
+
'~/custom-plugins/foo.client.js', // only in client side
|
|
1156
|
+
'~/custom-plugins/bar.server.js', // only in server side
|
|
1157
|
+
'~/custom-plugins/baz.js', // both client & server
|
|
1158
|
+
{ src: '~/custom-plugins/both-sides.js' },
|
|
1159
|
+
{ src: '~/custom-plugins/client-only.js', mode: 'client' }, // only on client side
|
|
1160
|
+
{ src: '~/custom-plugins/server-only.js', mode: 'server' }, // only on server side
|
|
1161
|
+
],
|
|
1162
|
+
})
|
|
1691
1163
|
```
|
|
1692
1164
|
|
|
1693
1165
|
## postcss
|
|
@@ -1789,17 +1261,34 @@ Values are automatically replaced by matching env variables at runtime, e.g. set
|
|
|
1789
1261
|
```
|
|
1790
1262
|
|
|
1791
1263
|
**Example**:
|
|
1792
|
-
```
|
|
1793
|
-
export default {
|
|
1794
|
-
|
|
1264
|
+
```ts
|
|
1265
|
+
export default defineNuxtConfig({
|
|
1266
|
+
runtimeConfig: {
|
|
1795
1267
|
apiKey: '', // Default to an empty string, automatically set at runtime using process.env.NUXT_API_KEY
|
|
1796
1268
|
public: {
|
|
1797
|
-
|
|
1798
|
-
}
|
|
1799
|
-
}
|
|
1800
|
-
}
|
|
1269
|
+
baseURL: '', // Exposed to the frontend as well.
|
|
1270
|
+
},
|
|
1271
|
+
},
|
|
1272
|
+
})
|
|
1801
1273
|
```
|
|
1802
1274
|
|
|
1275
|
+
## server
|
|
1276
|
+
|
|
1277
|
+
Configuration for Nuxt's server builder.
|
|
1278
|
+
|
|
1279
|
+
### `builder`
|
|
1280
|
+
|
|
1281
|
+
Specify the server builder to use for bundling the server part of your application.
|
|
1282
|
+
|
|
1283
|
+
By default, Nuxt uses `@nuxt/nitro-server`, which provides standalone Nitro integration. This architecture allows for different Nitro integration patterns, such as using Nitro as a Vite plugin (with the Vite Environment API).
|
|
1284
|
+
|
|
1285
|
+
- **Type**: `string | { bundle: (nuxt: Nuxt) => Promise<void> }`
|
|
1286
|
+
- **Default:** `"@nuxt/nitro-server"`
|
|
1287
|
+
|
|
1288
|
+
::callout{type="warning"}
|
|
1289
|
+
This option is intended for internal use and the API is not finalized. Please open an issue before relying on the current implementation.
|
|
1290
|
+
::
|
|
1291
|
+
|
|
1803
1292
|
## serverDir
|
|
1804
1293
|
|
|
1805
1294
|
Define the server directory of your Nuxt application, where Nitro routes, middleware and plugins are kept.
|
|
@@ -1818,17 +1307,19 @@ Each handler accepts the following options:
|
|
|
1818
1307
|
|
|
1819
1308
|
- **Type**: `array`
|
|
1820
1309
|
|
|
1821
|
-
**See**: [`server/` directory documentation](https://nuxt.com/docs/guide/directory-structure/server)
|
|
1310
|
+
**See**: [`server/` directory documentation](https://nuxt.com/docs/4.x/guide/directory-structure/server)
|
|
1822
1311
|
|
|
1823
1312
|
::callout
|
|
1824
1313
|
**Note**: Files from `server/api`, `server/middleware` and `server/routes` will be automatically registered by Nuxt.
|
|
1825
1314
|
::
|
|
1826
1315
|
|
|
1827
1316
|
**Example**:
|
|
1828
|
-
```
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1317
|
+
```ts
|
|
1318
|
+
export default defineNuxtConfig({
|
|
1319
|
+
serverHandlers: [
|
|
1320
|
+
{ route: '/path/foo/**:name', handler: '~/server/foohandler.ts' },
|
|
1321
|
+
],
|
|
1322
|
+
})
|
|
1832
1323
|
```
|
|
1833
1324
|
|
|
1834
1325
|
## sourcemap
|
|
@@ -1911,10 +1402,10 @@ If a relative path is specified, it will be relative to the `rootDir`.
|
|
|
1911
1402
|
- **Default:** `"app"` (Nuxt 4), `"."` (Nuxt 3 with `compatibilityMode: 3`)
|
|
1912
1403
|
|
|
1913
1404
|
**Example**:
|
|
1914
|
-
```
|
|
1915
|
-
export default {
|
|
1916
|
-
srcDir: 'app/'
|
|
1917
|
-
}
|
|
1405
|
+
```ts
|
|
1406
|
+
export default defineNuxtConfig({
|
|
1407
|
+
srcDir: 'app/',
|
|
1408
|
+
})
|
|
1918
1409
|
```
|
|
1919
1410
|
This expects the following folder structure:
|
|
1920
1411
|
```bash
|
|
@@ -2044,7 +1535,7 @@ If set to true, this will type check in development. You can restrict this to bu
|
|
|
2044
1535
|
- **Type**: `boolean`
|
|
2045
1536
|
- **Default:** `false`
|
|
2046
1537
|
|
|
2047
|
-
**See**: [Nuxt TypeScript docs](https://nuxt.com/docs/guide/concepts/typescript)
|
|
1538
|
+
**See**: [Nuxt TypeScript docs](https://nuxt.com/docs/4.x/guide/concepts/typescript)
|
|
2048
1539
|
|
|
2049
1540
|
## unhead
|
|
2050
1541
|
|
|
@@ -2062,8 +1553,9 @@ Enable the legacy compatibility mode for `unhead` module. This applies the follo
|
|
|
2062
1553
|
**Example**:
|
|
2063
1554
|
```ts
|
|
2064
1555
|
export default defineNuxtConfig({
|
|
2065
|
-
|
|
2066
|
-
|
|
1556
|
+
unhead: {
|
|
1557
|
+
legacy: true,
|
|
1558
|
+
},
|
|
2067
1559
|
})
|
|
2068
1560
|
```
|
|
2069
1561
|
|
|
@@ -2082,10 +1574,11 @@ An object that will be passed to `renderSSRHead` to customize the output.
|
|
|
2082
1574
|
**Example**:
|
|
2083
1575
|
```ts
|
|
2084
1576
|
export default defineNuxtConfig({
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
1577
|
+
unhead: {
|
|
1578
|
+
renderSSRHeadOptions: {
|
|
1579
|
+
omitLineBreaks: true,
|
|
1580
|
+
},
|
|
1581
|
+
},
|
|
2089
1582
|
})
|
|
2090
1583
|
```
|
|
2091
1584
|
|
|
@@ -2423,7 +1916,7 @@ Hard-replaces `typeof process`, `typeof window` and `typeof document` to tree-sh
|
|
|
2423
1916
|
|
|
2424
1917
|
### `analyze`
|
|
2425
1918
|
|
|
2426
|
-
Nuxt uses `webpack-bundle-analyzer` to visualize your bundles and how to optimize them.
|
|
1919
|
+
If you are using webpack, Nuxt uses `webpack-bundle-analyzer` to visualize your bundles and how to optimize them.
|
|
2427
1920
|
|
|
2428
1921
|
Set to `true` to enable bundle analysis, or pass an object with options: [for webpack](https://github.com/webpack-contrib/webpack-bundle-analyzer#options-for-plugin) or [for vite](https://github.com/btd/rollup-plugin-visualizer#options).
|
|
2429
1922
|
|
|
@@ -2438,10 +1931,14 @@ Set to `true` to enable bundle analysis, or pass an object with options: [for we
|
|
|
2438
1931
|
```
|
|
2439
1932
|
|
|
2440
1933
|
**Example**:
|
|
2441
|
-
```
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
1934
|
+
```ts
|
|
1935
|
+
export default defineNuxtConfig({
|
|
1936
|
+
webpack: {
|
|
1937
|
+
analyze: {
|
|
1938
|
+
analyzerMode: 'static',
|
|
1939
|
+
},
|
|
1940
|
+
},
|
|
1941
|
+
})
|
|
2445
1942
|
```
|
|
2446
1943
|
|
|
2447
1944
|
### `cssSourceMap`
|
|
@@ -2474,16 +1971,16 @@ Using [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extr
|
|
|
2474
1971
|
- **Default:** `true`
|
|
2475
1972
|
|
|
2476
1973
|
**Example**:
|
|
2477
|
-
```
|
|
2478
|
-
export default {
|
|
1974
|
+
```ts
|
|
1975
|
+
export default defineNuxtConfig({
|
|
2479
1976
|
webpack: {
|
|
2480
1977
|
extractCSS: true,
|
|
2481
1978
|
// or
|
|
2482
1979
|
extractCSS: {
|
|
2483
|
-
ignoreOrder: true
|
|
2484
|
-
}
|
|
2485
|
-
}
|
|
2486
|
-
}
|
|
1980
|
+
ignoreOrder: true,
|
|
1981
|
+
},
|
|
1982
|
+
},
|
|
1983
|
+
})
|
|
2487
1984
|
```
|
|
2488
1985
|
|
|
2489
1986
|
If you want to extract all your CSS to a single file, there is a workaround for this.
|
|
@@ -2493,8 +1990,8 @@ can also improve page performance by downloading and resolving only those resour
|
|
|
2493
1990
|
that are needed.
|
|
2494
1991
|
|
|
2495
1992
|
**Example**:
|
|
2496
|
-
```
|
|
2497
|
-
export default {
|
|
1993
|
+
```ts
|
|
1994
|
+
export default defineNuxtConfig({
|
|
2498
1995
|
webpack: {
|
|
2499
1996
|
extractCSS: true,
|
|
2500
1997
|
optimization: {
|
|
@@ -2504,13 +2001,13 @@ export default {
|
|
|
2504
2001
|
name: 'styles',
|
|
2505
2002
|
test: /\.(css|vue)$/,
|
|
2506
2003
|
chunks: 'all',
|
|
2507
|
-
enforce: true
|
|
2508
|
-
}
|
|
2509
|
-
}
|
|
2510
|
-
}
|
|
2511
|
-
}
|
|
2512
|
-
}
|
|
2513
|
-
}
|
|
2004
|
+
enforce: true,
|
|
2005
|
+
},
|
|
2006
|
+
},
|
|
2007
|
+
},
|
|
2008
|
+
},
|
|
2009
|
+
},
|
|
2010
|
+
})
|
|
2514
2011
|
```
|
|
2515
2012
|
|
|
2516
2013
|
### `filenames`
|
|
@@ -2527,10 +2024,14 @@ as most browsers will cache the asset and not detect the changes on first load.
|
|
|
2527
2024
|
This example changes fancy chunk names to numerical ids:
|
|
2528
2025
|
|
|
2529
2026
|
**Example**:
|
|
2530
|
-
```
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2027
|
+
```ts
|
|
2028
|
+
export default defineNuxtConfig({
|
|
2029
|
+
webpack: {
|
|
2030
|
+
filenames: {
|
|
2031
|
+
chunk: ({ isDev }) => (isDev ? '[name].js' : '[id].[contenthash].js'),
|
|
2032
|
+
},
|
|
2033
|
+
},
|
|
2034
|
+
})
|
|
2534
2035
|
```
|
|
2535
2036
|
|
|
2536
2037
|
#### `app`
|
|
@@ -2639,8 +2140,8 @@ See [css-loader](https://github.com/webpack-contrib/css-loader) for available op
|
|
|
2639
2140
|
**See**: [`file-loader` Options](https://github.com/webpack-contrib/file-loader#options)
|
|
2640
2141
|
|
|
2641
2142
|
**Default**:
|
|
2642
|
-
```
|
|
2643
|
-
{ esModule: false }
|
|
2143
|
+
```json
|
|
2144
|
+
{ "esModule": false }
|
|
2644
2145
|
```
|
|
2645
2146
|
|
|
2646
2147
|
##### `esModule`
|
|
@@ -2658,8 +2159,8 @@ See [css-loader](https://github.com/webpack-contrib/css-loader) for available op
|
|
|
2658
2159
|
**See**: [`file-loader` Options](https://github.com/webpack-contrib/file-loader#options)
|
|
2659
2160
|
|
|
2660
2161
|
**Default**:
|
|
2661
|
-
```
|
|
2662
|
-
{ esModule: false }
|
|
2162
|
+
```json
|
|
2163
|
+
{ "esModule": false }
|
|
2663
2164
|
```
|
|
2664
2165
|
|
|
2665
2166
|
##### `esModule`
|
|
@@ -2677,8 +2178,8 @@ See [css-loader](https://github.com/webpack-contrib/css-loader) for available op
|
|
|
2677
2178
|
**See**: [`file-loader` Options](https://github.com/webpack-contrib/file-loader#options)
|
|
2678
2179
|
|
|
2679
2180
|
**Default**:
|
|
2680
|
-
```
|
|
2681
|
-
{ esModule: false }
|
|
2181
|
+
```json
|
|
2182
|
+
{ "esModule": false }
|
|
2682
2183
|
```
|
|
2683
2184
|
|
|
2684
2185
|
##### `esModule`
|
|
@@ -2711,10 +2212,10 @@ See [css-loader](https://github.com/webpack-contrib/css-loader) for available op
|
|
|
2711
2212
|
**See**: [`sass-loader` Options](https://github.com/webpack-contrib/sass-loader#options)
|
|
2712
2213
|
|
|
2713
2214
|
**Default**:
|
|
2714
|
-
```
|
|
2215
|
+
```json
|
|
2715
2216
|
{
|
|
2716
|
-
sassOptions: {
|
|
2717
|
-
indentedSyntax: true
|
|
2217
|
+
"sassOptions": {
|
|
2218
|
+
"indentedSyntax": true
|
|
2718
2219
|
}
|
|
2719
2220
|
}
|
|
2720
2221
|
```
|
|
@@ -2849,15 +2350,20 @@ Add webpack plugins.
|
|
|
2849
2350
|
- **Type**: `array`
|
|
2850
2351
|
|
|
2851
2352
|
**Example**:
|
|
2852
|
-
```
|
|
2353
|
+
```ts
|
|
2853
2354
|
import webpack from 'webpack'
|
|
2854
2355
|
import { version } from './package.json'
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2356
|
+
|
|
2357
|
+
export default defineNuxtConfig({
|
|
2358
|
+
webpack: {
|
|
2359
|
+
plugins: [
|
|
2360
|
+
// ...
|
|
2361
|
+
new webpack.DefinePlugin({
|
|
2362
|
+
'process.VERSION': version,
|
|
2363
|
+
}),
|
|
2364
|
+
],
|
|
2365
|
+
},
|
|
2366
|
+
})
|
|
2861
2367
|
```
|
|
2862
2368
|
|
|
2863
2369
|
### `postcss`
|