@nuxt/docs 4.2.0 → 4.2.2
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 +1 -1
- package/1.getting-started/02.installation.md +3 -3
- package/1.getting-started/03.configuration.md +27 -27
- package/1.getting-started/04.views.md +5 -5
- package/1.getting-started/05.assets.md +8 -8
- package/1.getting-started/06.styling.md +15 -15
- package/1.getting-started/07.routing.md +10 -6
- package/1.getting-started/08.seo-meta.md +3 -3
- package/1.getting-started/09.transitions.md +10 -10
- package/1.getting-started/10.data-fetching.md +16 -16
- package/1.getting-started/11.state-management.md +3 -3
- package/1.getting-started/12.error-handling.md +6 -6
- package/1.getting-started/13.server.md +6 -6
- package/1.getting-started/14.layers.md +32 -13
- package/1.getting-started/16.deployment.md +1 -1
- package/1.getting-started/17.testing.md +35 -4
- package/1.getting-started/18.upgrade.md +42 -34
- 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 +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.assets.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.components.md +6 -6
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.composables.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.layouts.md +3 -3
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.middleware.md +5 -5
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.pages.md +17 -17
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.plugins.md +3 -7
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.utils.md +3 -3
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/3.app.md +4 -4
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/3.error.md +1 -3
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.content.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.modules.md +1 -1
- 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.public.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.server.md +7 -7
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.shared.md +3 -3
- package/{2.guide/1.directory-structure → 2.directory-structure}/2.env.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/2.nuxtignore.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/2.nuxtrc.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/3.nuxt-config.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/3.package.md +1 -1
- package/2.directory-structure/3.tsconfig.md +69 -0
- package/2.directory-structure/index.md +61 -0
- package/{2.guide → 3.guide}/0.index.md +4 -7
- package/{2.guide/2.concepts/3.rendering.md → 3.guide/1.concepts/1.rendering.md} +4 -30
- package/{2.guide/2.concepts/2.vuejs-development.md → 3.guide/1.concepts/10.vuejs-development.md} +7 -6
- package/{2.guide/2.concepts/10.nuxt-lifecycle.md → 3.guide/1.concepts/2.nuxt-lifecycle.md} +32 -25
- package/{2.guide/2.concepts/1.auto-imports.md → 3.guide/1.concepts/3.auto-imports.md} +7 -7
- 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 +1 -1
- package/{2.guide/2.concepts → 3.guide/1.concepts}/7.esm.md +3 -2
- package/{2.guide/2.concepts → 3.guide/1.concepts}/8.typescript.md +15 -38
- 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 +2 -2
- package/3.guide/3.ai/.navigation.yml +3 -0
- package/3.guide/3.ai/1.mcp.md +255 -0
- package/3.guide/3.ai/2.llms-txt.md +65 -0
- package/{2.guide → 3.guide}/4.recipes/1.custom-routing.md +5 -5
- package/{2.guide → 3.guide}/4.recipes/2.vite-plugin.md +1 -1
- package/{2.guide → 3.guide}/4.recipes/3.custom-usefetch.md +1 -1
- package/{2.guide → 3.guide}/4.recipes/4.sessions-and-authentication.md +1 -1
- package/{2.guide/3.going-further → 3.guide/5.going-further}/1.events.md +2 -3
- package/{2.guide/3.going-further → 3.guide/5.going-further}/1.experimental-features.md +10 -10
- package/{2.guide/3.going-further → 3.guide/5.going-further}/1.features.md +1 -1
- package/{2.guide/3.going-further → 3.guide/5.going-further}/1.internals.md +3 -2
- package/{2.guide/3.going-further → 3.guide/5.going-further}/10.runtime-config.md +2 -2
- package/{2.guide/3.going-further → 3.guide/5.going-further}/2.hooks.md +2 -2
- package/{2.guide/3.going-further → 3.guide/5.going-further}/3.modules.md +78 -11
- package/{2.guide/3.going-further → 3.guide/5.going-further}/6.nuxt-app.md +5 -5
- package/{2.guide/3.going-further → 3.guide/5.going-further}/7.layers.md +42 -25
- package/{2.guide/3.going-further → 3.guide/5.going-further}/9.debugging.md +1 -1
- package/{3.api → 4.api}/1.components/10.nuxt-picture.md +1 -1
- package/{3.api → 4.api}/1.components/11.teleports.md +1 -1
- 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 +3 -3
- package/{3.api → 4.api}/1.components/3.nuxt-layout.md +5 -5
- package/{3.api → 4.api}/1.components/4.nuxt-link.md +11 -11
- package/{3.api → 4.api}/1.components/5.nuxt-loading-indicator.md +1 -1
- package/{3.api → 4.api}/1.components/6.nuxt-error-boundary.md +1 -1
- package/{3.api → 4.api}/1.components/7.nuxt-welcome.md +2 -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 +76 -13
- package/4.api/2.composables/use-cookie.md +183 -0
- package/{3.api → 4.api}/2.composables/use-fetch.md +33 -33
- package/{3.api → 4.api}/2.composables/use-head-safe.md +37 -20
- package/4.api/2.composables/use-head.md +169 -0
- package/{3.api → 4.api}/2.composables/use-hydration.md +24 -18
- package/4.api/2.composables/use-lazy-async-data.md +96 -0
- package/4.api/2.composables/use-lazy-fetch.md +111 -0
- package/{3.api → 4.api}/2.composables/use-nuxt-app.md +7 -7
- package/{3.api → 4.api}/2.composables/use-nuxt-data.md +1 -1
- package/{3.api → 4.api}/2.composables/use-request-fetch.md +1 -1
- 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 +1 -1
- package/{3.api → 4.api}/2.composables/use-runtime-hook.md +1 -1
- package/{3.api → 4.api}/2.composables/use-state.md +1 -1
- package/{3.api → 4.api}/3.utils/$fetch.md +1 -1
- 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 +0 -2
- package/{3.api → 4.api}/3.utils/define-lazy-hydration-component.md +4 -4
- package/{3.api → 4.api}/3.utils/define-nuxt-component.md +1 -1
- package/4.api/3.utils/define-nuxt-plugin.md +102 -0
- package/{3.api → 4.api}/3.utils/define-nuxt-route-middleware.md +2 -2
- package/{3.api → 4.api}/3.utils/define-page-meta.md +14 -14
- package/{3.api → 4.api}/3.utils/navigate-to.md +15 -15
- 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/refresh-cookie.md +1 -3
- package/{3.api → 4.api}/3.utils/update-app-config.md +2 -2
- package/{3.api → 4.api}/4.commands/add.md +10 -10
- 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 +18 -18
- package/{3.api → 4.api}/5.kit/10.templates.md +23 -23
- package/{3.api → 4.api}/5.kit/11.nitro.md +35 -35
- package/{3.api → 4.api}/5.kit/14.builder.md +21 -21
- package/{3.api → 4.api}/5.kit/16.layers.md +12 -12
- package/{3.api → 4.api}/5.kit/2.programmatic.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/4.api/6.advanced/1.hooks.md +105 -0
- package/{3.api → 4.api}/6.nuxt-config.md +29 -28
- package/5.community/3.reporting-bugs.md +1 -1
- package/5.community/4.contribution.md +1 -1
- package/5.community/5.framework-contribution.md +8 -8
- package/5.community/6.roadmap.md +25 -25
- package/5.community/7.changelog.md +10 -0
- package/6.bridge/1.overview.md +1 -1
- package/6.bridge/2.typescript.md +1 -1
- package/6.bridge/3.bridge-composition-api.md +1 -1
- package/6.bridge/4.plugins-and-middleware.md +2 -2
- package/7.migration/11.server.md +1 -1
- package/7.migration/2.configuration.md +3 -3
- package/7.migration/20.module-authors.md +1 -1
- package/7.migration/3.auto-imports.md +1 -1
- package/7.migration/5.plugins-and-middleware.md +2 -2
- package/7.migration/6.pages-and-layouts.md +6 -6
- package/README.md +1 -1
- package/package.json +1 -1
- package/2.guide/1.directory-structure/3.tsconfig.md +0 -38
- package/3.api/2.composables/use-cookie.md +0 -183
- package/3.api/2.composables/use-head.md +0 -69
- package/3.api/2.composables/use-lazy-async-data.md +0 -47
- package/3.api/2.composables/use-lazy-fetch.md +0 -55
- package/3.api/2.composables/use-router.md +0 -94
- package/3.api/3.utils/define-nuxt-plugin.md +0 -102
- 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}/1.app/.navigation.yml +0 -0
- /package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/3.app-config.md +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 → 3.guide}/4.recipes/.navigation.yml +0 -0
- /package/{2.guide/3.going-further → 3.guide/5.going-further}/.navigation.yml +0 -0
- /package/{2.guide/3.going-further → 3.guide/5.going-further}/11.nightly-release-channel.md +0 -0
- /package/{2.guide/3.going-further → 3.guide/5.going-further}/4.kit.md +0 -0
- /package/{2.guide/3.going-further → 3.guide/5.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/1.nuxt-client-fallback.md +0 -0
- /package/{3.api → 4.api}/1.components/8.nuxt-island.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-error.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-loading-indicator.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-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-seo-meta.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-server-seo-meta.md +0 -0
- /package/{3.api → 4.api}/3.utils/.navigation.yml +0 -0
- /package/{3.api → 4.api}/3.utils/clear-error.md +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/create-error.md +0 -0
- /package/{3.api → 4.api}/3.utils/define-route-rules.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/preload-route-components.md +0 -0
- /package/{3.api → 4.api}/3.utils/prerender-routes.md +0 -0
- /package/{3.api → 4.api}/3.utils/refresh-nuxt-data.md +0 -0
- /package/{3.api → 4.api}/3.utils/reload-nuxt-app.md +0 -0
- /package/{3.api → 4.api}/3.utils/set-page-layout.md +0 -0
- /package/{3.api → 4.api}/3.utils/set-response-status.md +0 -0
- /package/{3.api → 4.api}/3.utils/show-error.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/12.resolving.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/3.compatibility.md +0 -0
- /package/{3.api → 4.api}/5.kit/6.context.md +0 -0
- /package/{3.api → 4.api}/5.kit/7.pages.md +0 -0
- /package/{3.api → 4.api}/5.kit/8.layout.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}/index.md +0 -0
|
@@ -29,7 +29,7 @@ Because the data inside `useState` will be serialized to JSON, it is important t
|
|
|
29
29
|
|
|
30
30
|
## Using `shallowRef`
|
|
31
31
|
|
|
32
|
-
If you don't need your state to be deeply reactive, you can combine `useState` with [`shallowRef`](https://vuejs.org/api/reactivity-advanced
|
|
32
|
+
If you don't need your state to be deeply reactive, you can combine `useState` with [`shallowRef`](https://vuejs.org/api/reactivity-advanced#shallowref). This can improve performance when your state contains large objects and arrays.
|
|
33
33
|
|
|
34
34
|
```ts
|
|
35
35
|
const state = useState('my-shallow-state', () => shallowRef({ deep: 'not reactive' }))
|
|
@@ -11,7 +11,7 @@ links:
|
|
|
11
11
|
Nuxt uses [ofetch](https://github.com/unjs/ofetch) to expose globally the `$fetch` helper for making HTTP requests within your Vue app or API routes.
|
|
12
12
|
|
|
13
13
|
::tip{icon="i-lucide-rocket"}
|
|
14
|
-
During server-side rendering, calling `$fetch` to fetch your internal [API routes](/docs/4.x/
|
|
14
|
+
During server-side rendering, calling `$fetch` to fetch your internal [API routes](/docs/4.x/directory-structure/server) will directly call the relevant function (emulating the request), **saving an additional API call**.
|
|
15
15
|
::
|
|
16
16
|
|
|
17
17
|
::note{color="blue" icon="i-lucide-info"}
|
|
@@ -9,7 +9,7 @@ links:
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
::warning
|
|
12
|
-
`abortNavigation` is only usable inside a [route middleware handler](/docs/4.x/
|
|
12
|
+
`abortNavigation` is only usable inside a [route middleware handler](/docs/4.x/directory-structure/app/middleware).
|
|
13
13
|
::
|
|
14
14
|
|
|
15
15
|
## Type
|
|
@@ -22,7 +22,7 @@ export function abortNavigation (err?: Error | string): false
|
|
|
22
22
|
|
|
23
23
|
### `err`
|
|
24
24
|
|
|
25
|
-
- **Type**: [`Error`](https://developer.mozilla.org/
|
|
25
|
+
- **Type**: [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) | `string`
|
|
26
26
|
|
|
27
27
|
Optional error to be thrown by `abortNavigation`.
|
|
28
28
|
|
|
@@ -60,7 +60,7 @@ export default defineNuxtRouteMiddleware((to, from) => {
|
|
|
60
60
|
|
|
61
61
|
### `err` as an Error Object
|
|
62
62
|
|
|
63
|
-
You can pass the error as an [`Error`](https://developer.mozilla.org/
|
|
63
|
+
You can pass the error as an [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object, e.g. caught by the `catch`-block:
|
|
64
64
|
|
|
65
65
|
```ts [app/middleware/auth.ts]
|
|
66
66
|
export default defineNuxtRouteMiddleware((to, from) => {
|
|
@@ -9,7 +9,7 @@ links:
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
::note
|
|
12
|
-
Route middleware are navigation guards stored in the [`app/middleware/`](/docs/4.x/
|
|
12
|
+
Route middleware are navigation guards stored in the [`app/middleware/`](/docs/4.x/directory-structure/app/middleware) directory of your Nuxt application (unless [set otherwise](/docs/4.x/api/nuxt-config#middleware)).
|
|
13
13
|
::
|
|
14
14
|
|
|
15
15
|
## Type
|
|
@@ -42,7 +42,7 @@ Read more about the options for `hydrate-on-visible`.
|
|
|
42
42
|
::
|
|
43
43
|
|
|
44
44
|
::note
|
|
45
|
-
Under the hood, this uses Vue's built-in [`hydrateOnVisible` strategy](https://vuejs.org/guide/components/async
|
|
45
|
+
Under the hood, this uses Vue's built-in [`hydrateOnVisible` strategy](https://vuejs.org/guide/components/async#hydrate-on-visible).
|
|
46
46
|
::
|
|
47
47
|
|
|
48
48
|
### Idle Strategy
|
|
@@ -70,7 +70,7 @@ The `hydrateOnIdle` prop is optional. You can pass a positive number to specify
|
|
|
70
70
|
Idle strategy is for components that can be hydrated when the browser is idle.
|
|
71
71
|
|
|
72
72
|
::note
|
|
73
|
-
Under the hood, this uses Vue's built-in [`hydrateOnIdle` strategy](https://vuejs.org/guide/components/async
|
|
73
|
+
Under the hood, this uses Vue's built-in [`hydrateOnIdle` strategy](https://vuejs.org/guide/components/async#hydrate-on-idle).
|
|
74
74
|
::
|
|
75
75
|
|
|
76
76
|
### Interaction Strategy
|
|
@@ -99,7 +99,7 @@ const LazyHydrationMyComponent = defineLazyHydrationComponent(
|
|
|
99
99
|
The `hydrateOnInteraction` prop is optional. If you do not pass an event or a list of events, it defaults to hydrating on `pointerenter`, `click`, and `focus`.
|
|
100
100
|
|
|
101
101
|
::note
|
|
102
|
-
Under the hood, this uses Vue's built-in [`hydrateOnInteraction` strategy](https://vuejs.org/guide/components/async
|
|
102
|
+
Under the hood, this uses Vue's built-in [`hydrateOnInteraction` strategy](https://vuejs.org/guide/components/async#hydrate-on-interaction).
|
|
103
103
|
::
|
|
104
104
|
|
|
105
105
|
### Media Query Strategy
|
|
@@ -126,7 +126,7 @@ const LazyHydrationMyComponent = defineLazyHydrationComponent(
|
|
|
126
126
|
```
|
|
127
127
|
|
|
128
128
|
::note
|
|
129
|
-
Under the hood, this uses Vue's built-in [`hydrateOnMediaQuery` strategy](https://vuejs.org/guide/components/async
|
|
129
|
+
Under the hood, this uses Vue's built-in [`hydrateOnMediaQuery` strategy](https://vuejs.org/guide/components/async#hydrate-on-media-query).
|
|
130
130
|
::
|
|
131
131
|
|
|
132
132
|
### Time Strategy
|
|
@@ -9,7 +9,7 @@ links:
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
::note
|
|
12
|
-
`defineNuxtComponent()` is a helper function for defining type safe Vue components using options API similar to [`defineComponent()`](https://vuejs.org/api/general
|
|
12
|
+
`defineNuxtComponent()` is a helper function for defining type safe Vue components using options API similar to [`defineComponent()`](https://vuejs.org/api/general#definecomponent). `defineNuxtComponent()` wrapper also adds support for `asyncData` and `head` component options.
|
|
13
13
|
::
|
|
14
14
|
|
|
15
15
|
::note
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "defineNuxtPlugin"
|
|
3
|
+
description: defineNuxtPlugin() is a helper function for creating Nuxt plugins.
|
|
4
|
+
links:
|
|
5
|
+
- label: Source
|
|
6
|
+
icon: i-simple-icons-github
|
|
7
|
+
to: https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/app/nuxt.ts
|
|
8
|
+
size: xs
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
`defineNuxtPlugin` is a helper function for creating Nuxt plugins with enhanced functionality and type safety. This utility normalizes different plugin formats into a consistent structure that works seamlessly within Nuxt's plugin system.
|
|
12
|
+
|
|
13
|
+
```ts twoslash [plugins/hello.ts]
|
|
14
|
+
export default defineNuxtPlugin((nuxtApp) => {
|
|
15
|
+
// Doing something with nuxtApp
|
|
16
|
+
})
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
:read-more{to="/docs/4.x/directory-structure/app/plugins#creating-plugins"}
|
|
20
|
+
|
|
21
|
+
## Type
|
|
22
|
+
|
|
23
|
+
```ts [Signature]
|
|
24
|
+
export function defineNuxtPlugin<T extends Record<string, unknown>> (plugin: Plugin<T> | ObjectPlugin<T>): Plugin<T> & ObjectPlugin<T>
|
|
25
|
+
|
|
26
|
+
type Plugin<T> = (nuxt: NuxtApp) => Promise<void> | Promise<{ provide?: T }> | void | { provide?: T }
|
|
27
|
+
|
|
28
|
+
interface ObjectPlugin<T> {
|
|
29
|
+
name?: string
|
|
30
|
+
enforce?: 'pre' | 'default' | 'post'
|
|
31
|
+
dependsOn?: string[]
|
|
32
|
+
order?: number
|
|
33
|
+
parallel?: boolean
|
|
34
|
+
setup?: Plugin<T>
|
|
35
|
+
hooks?: Partial<RuntimeNuxtHooks>
|
|
36
|
+
env?: {
|
|
37
|
+
islands?: boolean
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Parameters
|
|
43
|
+
|
|
44
|
+
**plugin**: A plugin can be defined in two ways:
|
|
45
|
+
1. **Function Plugin**: A function that receives the [`NuxtApp`](/docs/4.x/guide/going-further/internals#the-nuxtapp-interface) instance and can return a promise with a potential object with a [`provide`](/docs/4.x/directory-structure/app/plugins#providing-helpers) property if you want to provide a helper on [`NuxtApp`](/docs/4.x/guide/going-further/internals#the-nuxtapp-interface) instance.
|
|
46
|
+
2. **Object Plugin**: An object that can include various properties to configure the plugin's behavior, such as `name`, `enforce`, `dependsOn`, `order`, `parallel`, `setup`, `hooks`, and `env`.
|
|
47
|
+
|
|
48
|
+
| Property | Type | Required | Description |
|
|
49
|
+
|-------------|----------------------------------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
50
|
+
| `name` | `string` | `false` | Optional name for the plugin, useful for debugging and dependency management. |
|
|
51
|
+
| `enforce` | `'pre'` \| `'default'` \| `'post'` | `false` | Controls when the plugin runs relative to other plugins. |
|
|
52
|
+
| `dependsOn` | `string[]` | `false` | Array of plugin names this plugin depends on. Ensures proper execution order. |
|
|
53
|
+
| `order` | `number` | `false` | This allows more granular control over plugin order and should only be used by advanced users. **It overrides the value of `enforce` and is used to sort plugins.** |
|
|
54
|
+
| `parallel` | `boolean` | `false` | Whether to execute the plugin in parallel with other parallel plugins. |
|
|
55
|
+
| `setup` | `Plugin<T>`{lang="ts"} | `false` | The main plugin function, equivalent to a function plugin. |
|
|
56
|
+
| `hooks` | `Partial<RuntimeNuxtHooks>`{lang="ts"} | `false` | Nuxt app runtime hooks to register directly. |
|
|
57
|
+
| `env` | `{ islands?: boolean }`{lang="ts"} | `false` | Set this value to `false` if you don't want the plugin to run when rendering server-only or island components. |
|
|
58
|
+
|
|
59
|
+
:video-accordion{title="Watch a video from Alexander Lichter about the Object Syntax for Nuxt plugins" videoId="2aXZyXB1QGQ"}
|
|
60
|
+
|
|
61
|
+
## Examples
|
|
62
|
+
|
|
63
|
+
### Basic Usage
|
|
64
|
+
|
|
65
|
+
The example below demonstrates a simple plugin that adds global functionality:
|
|
66
|
+
|
|
67
|
+
```ts twoslash [plugins/hello.ts]
|
|
68
|
+
export default defineNuxtPlugin((nuxtApp) => {
|
|
69
|
+
// Add a global method
|
|
70
|
+
return {
|
|
71
|
+
provide: {
|
|
72
|
+
hello: (name: string) => `Hello ${name}!`,
|
|
73
|
+
},
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Object Syntax Plugin
|
|
79
|
+
|
|
80
|
+
The example below shows the object syntax with advanced configuration:
|
|
81
|
+
|
|
82
|
+
```ts twoslash [plugins/advanced.ts]
|
|
83
|
+
export default defineNuxtPlugin({
|
|
84
|
+
name: 'my-plugin',
|
|
85
|
+
enforce: 'pre',
|
|
86
|
+
async setup (nuxtApp) {
|
|
87
|
+
// Plugin setup logic
|
|
88
|
+
const data = await $fetch('/api/config')
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
provide: {
|
|
92
|
+
config: data,
|
|
93
|
+
},
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
hooks: {
|
|
97
|
+
'app:created' () {
|
|
98
|
+
console.log('App created!')
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
})
|
|
102
|
+
```
|
|
@@ -8,7 +8,7 @@ links:
|
|
|
8
8
|
size: xs
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
Route middleware are stored in the [`app/middleware/`](/docs/4.x/
|
|
11
|
+
Route middleware are stored in the [`app/middleware/`](/docs/4.x/directory-structure/app/middleware) of your Nuxt application (unless [set otherwise](/docs/4.x/api/nuxt-config#middleware)).
|
|
12
12
|
|
|
13
13
|
## Type
|
|
14
14
|
|
|
@@ -28,7 +28,7 @@ interface RouteMiddleware {
|
|
|
28
28
|
|
|
29
29
|
A function that takes two Vue Router's route location objects as parameters: the next route `to` as the first, and the current route `from` as the second.
|
|
30
30
|
|
|
31
|
-
Learn more about available properties of `RouteLocationNormalized` in the **[Vue Router docs](https://router.vuejs.org/api/type-aliases/
|
|
31
|
+
Learn more about available properties of `RouteLocationNormalized` in the **[Vue Router docs](https://router.vuejs.org/api/type-aliases/routelocationnormalized)**.
|
|
32
32
|
|
|
33
33
|
## Examples
|
|
34
34
|
|
|
@@ -8,7 +8,7 @@ links:
|
|
|
8
8
|
size: xs
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
`definePageMeta` is a compiler macro that you can use to set metadata for your **page** components located in the [`app/pages/`](/docs/4.x/
|
|
11
|
+
`definePageMeta` is a compiler macro that you can use to set metadata for your **page** components located in the [`app/pages/`](/docs/4.x/directory-structure/app/pages) directory (unless [set otherwise](/docs/4.x/api/nuxt-config#pages)). This way you can set custom metadata for each static or dynamic route of your Nuxt application.
|
|
12
12
|
|
|
13
13
|
```vue [app/pages/some-page.vue]
|
|
14
14
|
<script setup lang="ts">
|
|
@@ -18,7 +18,7 @@ definePageMeta({
|
|
|
18
18
|
</script>
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
:read-more{to="/docs/4.x/
|
|
21
|
+
:read-more{to="/docs/4.x/directory-structure/app/pages#page-metadata"}
|
|
22
22
|
|
|
23
23
|
## Type
|
|
24
24
|
|
|
@@ -56,13 +56,13 @@ interface PageMeta {
|
|
|
56
56
|
|
|
57
57
|
- **Type**: `string`
|
|
58
58
|
|
|
59
|
-
You may define a name for this page's route. By default, name is generated based on path inside the [`app/pages/` directory](/docs/4.x/
|
|
59
|
+
You may define a name for this page's route. By default, name is generated based on path inside the [`app/pages/` directory](/docs/4.x/directory-structure/app/pages).
|
|
60
60
|
|
|
61
61
|
**`path`**
|
|
62
62
|
|
|
63
63
|
- **Type**: `string`
|
|
64
64
|
|
|
65
|
-
You may define a [custom regular expression](/docs/4.x/api/
|
|
65
|
+
You may define a [custom regular expression](/docs/4.x/api/utils/define-page-meta#using-a-custom-regular-expression) if you have a more complex pattern than can be expressed with the file name.
|
|
66
66
|
|
|
67
67
|
**`props`**
|
|
68
68
|
|
|
@@ -78,9 +78,9 @@ interface PageMeta {
|
|
|
78
78
|
|
|
79
79
|
**`keepalive`**
|
|
80
80
|
|
|
81
|
-
- **Type**: `boolean` | [`KeepAliveProps`](https://vuejs.org/api/built-in-components
|
|
81
|
+
- **Type**: `boolean` | [`KeepAliveProps`](https://vuejs.org/api/built-in-components#keepalive)
|
|
82
82
|
|
|
83
|
-
Set to `true` when you want to preserve page state across route changes or use the [`KeepAliveProps`](https://vuejs.org/api/built-in-components
|
|
83
|
+
Set to `true` when you want to preserve page state across route changes or use the [`KeepAliveProps`](https://vuejs.org/api/built-in-components#keepalive) for a fine-grained control.
|
|
84
84
|
|
|
85
85
|
**`key`**
|
|
86
86
|
|
|
@@ -96,19 +96,19 @@ interface PageMeta {
|
|
|
96
96
|
|
|
97
97
|
**`layoutTransition`**
|
|
98
98
|
|
|
99
|
-
- **Type**: `boolean` | [`TransitionProps`](https://vuejs.org/api/built-in-components
|
|
99
|
+
- **Type**: `boolean` | [`TransitionProps`](https://vuejs.org/api/built-in-components#transition)
|
|
100
100
|
|
|
101
101
|
Set name of the transition to apply for current layout. You can also set this value to `false` to disable the layout transition.
|
|
102
102
|
|
|
103
103
|
**`middleware`**
|
|
104
104
|
|
|
105
|
-
- **Type**: `MiddlewareKey` | [`NavigationGuard`](https://router.vuejs.org/api/interfaces/
|
|
105
|
+
- **Type**: `MiddlewareKey` | [`NavigationGuard`](https://router.vuejs.org/api/interfaces/navigationguard) | `Array<MiddlewareKey | NavigationGuard>`
|
|
106
106
|
|
|
107
|
-
Define anonymous or named middleware directly within `definePageMeta`. Learn more about [route middleware](/docs/4.x/
|
|
107
|
+
Define anonymous or named middleware directly within `definePageMeta`. Learn more about [route middleware](/docs/4.x/directory-structure/app/middleware).
|
|
108
108
|
|
|
109
109
|
**`pageTransition`**
|
|
110
110
|
|
|
111
|
-
- **Type**: `boolean` | [`TransitionProps`](https://vuejs.org/api/built-in-components
|
|
111
|
+
- **Type**: `boolean` | [`TransitionProps`](https://vuejs.org/api/built-in-components#transition)
|
|
112
112
|
|
|
113
113
|
Set name of the transition to apply for current page. You can also set this value to `false` to disable the page transition.
|
|
114
114
|
|
|
@@ -122,7 +122,7 @@ interface PageMeta {
|
|
|
122
122
|
|
|
123
123
|
**`redirect`**
|
|
124
124
|
|
|
125
|
-
- **Type**: [`RouteRecordRedirectOption`](https://router.vuejs.org/guide/essentials/redirect-and-alias
|
|
125
|
+
- **Type**: [`RouteRecordRedirectOption`](https://router.vuejs.org/guide/essentials/redirect-and-alias)
|
|
126
126
|
|
|
127
127
|
Where to redirect if the route is directly matched. The redirection happens before any navigation guard and triggers a new navigation with the new target location.
|
|
128
128
|
|
|
@@ -142,7 +142,7 @@ interface PageMeta {
|
|
|
142
142
|
|
|
143
143
|
- **Type**: `any`
|
|
144
144
|
|
|
145
|
-
Apart from the above properties, you can also set **custom** metadata. You may wish to do so in a type-safe way by [augmenting the type of the `meta` object](/docs/4.x/
|
|
145
|
+
Apart from the above properties, you can also set **custom** metadata. You may wish to do so in a type-safe way by [augmenting the type of the `meta` object](/docs/4.x/directory-structure/app/pages/#typing-custom-metadata).
|
|
146
146
|
|
|
147
147
|
## Examples
|
|
148
148
|
|
|
@@ -215,11 +215,11 @@ definePageMeta({
|
|
|
215
215
|
</script>
|
|
216
216
|
```
|
|
217
217
|
|
|
218
|
-
For more examples see [Vue Router's Matching Syntax](https://router.vuejs.org/guide/essentials/route-matching-syntax
|
|
218
|
+
For more examples see [Vue Router's Matching Syntax](https://router.vuejs.org/guide/essentials/route-matching-syntax).
|
|
219
219
|
|
|
220
220
|
### Defining Layout
|
|
221
221
|
|
|
222
|
-
You can define the layout that matches the layout's file name located (by default) in the [`app/layouts/` directory](/docs/4.x/
|
|
222
|
+
You can define the layout that matches the layout's file name located (by default) in the [`app/layouts/` directory](/docs/4.x/directory-structure/app/layouts). You can also disable the layout by setting the `layout` to `false`:
|
|
223
223
|
|
|
224
224
|
```vue [app/pages/some-page.vue]
|
|
225
225
|
<script setup lang="ts">
|
|
@@ -17,7 +17,7 @@ Make sure to always use `await` or `return` on result of `navigateTo` when calli
|
|
|
17
17
|
::
|
|
18
18
|
|
|
19
19
|
::note
|
|
20
|
-
`navigateTo` cannot be used within Nitro routes. To perform a server-side redirect in Nitro routes, use [`sendRedirect`](https://h3.dev/utils/response#
|
|
20
|
+
`navigateTo` cannot be used within Nitro routes. To perform a server-side redirect in Nitro routes, use [`sendRedirect`](https://h3.dev/utils/response#redirectlocation-status-statustext) instead.
|
|
21
21
|
::
|
|
22
22
|
|
|
23
23
|
### Within a Vue Component
|
|
@@ -68,7 +68,7 @@ export default defineNuxtRouteMiddleware((to, from) => {
|
|
|
68
68
|
|
|
69
69
|
In this case, `navigateTo` will be executed but not returned, which may lead to unexpected behavior.
|
|
70
70
|
|
|
71
|
-
:read-more{to="/docs/4.x/
|
|
71
|
+
:read-more{to="/docs/4.x/directory-structure/app/middleware"}
|
|
72
72
|
|
|
73
73
|
### Navigating to an External URL
|
|
74
74
|
|
|
@@ -119,7 +119,7 @@ await navigateTo('https://nuxt.com', {
|
|
|
119
119
|
```ts [Signature]
|
|
120
120
|
export function navigateTo (
|
|
121
121
|
to: RouteLocationRaw | undefined | null,
|
|
122
|
-
options?: NavigateToOptions
|
|
122
|
+
options?: NavigateToOptions,
|
|
123
123
|
): Promise<void | NavigationFailure | false> | false | void | RouteLocationRaw
|
|
124
124
|
|
|
125
125
|
interface NavigateToOptions {
|
|
@@ -148,7 +148,7 @@ type OpenWindowFeatures = {
|
|
|
148
148
|
|
|
149
149
|
### `to`
|
|
150
150
|
|
|
151
|
-
**Type**: [`RouteLocationRaw`](https://router.vuejs.org/api/interfaces/
|
|
151
|
+
**Type**: [`RouteLocationRaw`](https://router.vuejs.org/api/interfaces/routelocationoptions) | `undefined` | `null`
|
|
152
152
|
|
|
153
153
|
**Default**: `'/'`
|
|
154
154
|
|
|
@@ -186,9 +186,9 @@ An object accepting the following properties:
|
|
|
186
186
|
- **Type**: `number`
|
|
187
187
|
- **Default**: `302`
|
|
188
188
|
|
|
189
|
-
- `navigateTo` redirects to the given path and sets the redirect code to [`302 Found`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302) by default when the redirection takes place on the server side.
|
|
189
|
+
- `navigateTo` redirects to the given path and sets the redirect code to [`302 Found`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/302) by default when the redirection takes place on the server side.
|
|
190
190
|
|
|
191
|
-
This default behavior can be modified by providing different `redirectCode`. Commonly, [`301 Moved Permanently`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/301) can be used for permanent redirections.
|
|
191
|
+
This default behavior can be modified by providing different `redirectCode`. Commonly, [`301 Moved Permanently`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/301) can be used for permanent redirections.
|
|
192
192
|
|
|
193
193
|
- `external`
|
|
194
194
|
|
|
@@ -217,14 +217,14 @@ An object accepting the following properties:
|
|
|
217
217
|
|
|
218
218
|
- An object accepting the following properties:
|
|
219
219
|
|
|
220
|
-
| Property
|
|
221
|
-
|
|
222
|
-
| `popup`
|
|
223
|
-
| `width` or `innerWidth`
|
|
224
|
-
| `height` or `innerHeight` | `number` | Specifies the content area's height (minimum 100 pixels), including scrollbars.
|
|
225
|
-
| `left` or `screenX`
|
|
226
|
-
| `top` or `screenY`
|
|
227
|
-
| `noopener`
|
|
228
|
-
| `noreferrer`
|
|
220
|
+
| Property | Type | Description |
|
|
221
|
+
|---------------------------|-----------|------------------------------------------------------------------------------------------------|
|
|
222
|
+
| `popup` | `boolean` | Requests a minimal popup window instead of a new tab, with UI features decided by the browser. |
|
|
223
|
+
| `width` or `innerWidth` | `number` | Specifies the content area's width (minimum 100 pixels), including scrollbars. |
|
|
224
|
+
| `height` or `innerHeight` | `number` | Specifies the content area's height (minimum 100 pixels), including scrollbars. |
|
|
225
|
+
| `left` or `screenX` | `number` | Sets the horizontal position of the new window relative to the left edge of the screen. |
|
|
226
|
+
| `top` or `screenY` | `number` | Sets the vertical position of the new window relative to the top edge of the screen. |
|
|
227
|
+
| `noopener` | `boolean` | Prevents the new window from accessing the originating window via `window.opener`. |
|
|
228
|
+
| `noreferrer` | `boolean` | Prevents the Referer header from being sent and implicitly enables `noopener`. |
|
|
229
229
|
|
|
230
230
|
Refer to the [documentation](https://developer.mozilla.org/en-US/docs/Web/API/Window/open#windowfeatures) for more detailed information on the **windowFeatures** properties.
|
|
@@ -8,4 +8,4 @@ links:
|
|
|
8
8
|
size: xs
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
:read-more{icon="i-simple-icons-vuedotjs" to="https://router.vuejs.org/api/functions/
|
|
11
|
+
:read-more{icon="i-simple-icons-vuedotjs" to="https://router.vuejs.org/api/functions/onbeforerouteleave" title="Vue Router Docs" target="_blank"}
|
|
@@ -8,4 +8,4 @@ links:
|
|
|
8
8
|
size: xs
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
:read-more{icon="i-simple-icons-vuedotjs" to="https://router.vuejs.org/api/functions/
|
|
11
|
+
:read-more{icon="i-simple-icons-vuedotjs" to="https://router.vuejs.org/api/functions/onbeforerouteupdate" title="Vue Router Docs" target="_blank"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "refreshCookie"
|
|
3
3
|
description: "Refresh useCookie values manually when a cookie has changed"
|
|
4
|
-
navigation:
|
|
5
|
-
badge: New
|
|
6
4
|
links:
|
|
7
5
|
- label: Source
|
|
8
6
|
icon: i-simple-icons-github
|
|
@@ -36,7 +34,7 @@ const loggedIn = computed(() => !!tokenCookie.value)
|
|
|
36
34
|
```
|
|
37
35
|
|
|
38
36
|
::note{to="/docs/4.x/guide/going-further/experimental-features#cookiestore"}
|
|
39
|
-
|
|
37
|
+
Since [Nuxt v3.12.0](https://github.com/nuxt/nuxt/releases/tag/v3.12.0), the experimental `cookieStore` option is enabled by default. It automatically refreshes the `useCookie` value when cookies change in the browser.
|
|
40
38
|
::
|
|
41
39
|
|
|
42
40
|
## Type
|
|
@@ -9,7 +9,7 @@ links:
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
::note
|
|
12
|
-
Updates the [`app.config`](/docs/4.x/
|
|
12
|
+
Updates the [`app.config`](/docs/4.x/directory-structure/app/app-config) using deep assignment. Existing (nested) properties will be preserved.
|
|
13
13
|
::
|
|
14
14
|
|
|
15
15
|
## Usage
|
|
@@ -25,4 +25,4 @@ updateAppConfig(newAppConfig)
|
|
|
25
25
|
console.log(appConfig) // { foo: 'baz' }
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
:read-more{to="/docs/4.x/
|
|
28
|
+
:read-more{to="/docs/4.x/directory-structure/app/app-config"}
|
|
@@ -14,23 +14,23 @@ npx nuxt add <TEMPLATE> <NAME> [--cwd=<directory>] [--logLevel=<silent|info|verb
|
|
|
14
14
|
```
|
|
15
15
|
<!--/add-cmd-->
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
## Arguments
|
|
18
18
|
|
|
19
19
|
<!--add-args-->
|
|
20
|
-
Argument
|
|
21
|
-
|
|
22
|
-
`TEMPLATE` | Specify which template to generate (options: <api\|app\|app-config\|component\|composable\|error\|layer\|layout\|middleware\|module\|page\|plugin\|server-middleware\|server-plugin\|server-route\|server-util>)
|
|
23
|
-
`NAME`
|
|
20
|
+
| Argument | Description |
|
|
21
|
+
|------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
22
|
+
| `TEMPLATE` | Specify which template to generate (options: <api\|app\|app-config\|component\|composable\|error\|layer\|layout\|middleware\|module\|page\|plugin\|server-middleware\|server-plugin\|server-route\|server-util>) |
|
|
23
|
+
| `NAME` | Specify name of the generated file |
|
|
24
24
|
<!--/add-args-->
|
|
25
25
|
|
|
26
26
|
### Options
|
|
27
27
|
|
|
28
28
|
<!--add-opts-->
|
|
29
|
-
Option
|
|
30
|
-
|
|
31
|
-
`--cwd=<directory>`
|
|
32
|
-
`--logLevel=<silent\|info\|verbose>` |
|
|
33
|
-
`--force`
|
|
29
|
+
| Option | Default | Description |
|
|
30
|
+
|--------------------------------------|---------|------------------------------------------|
|
|
31
|
+
| `--cwd=<directory>` | `.` | Specify the working directory |
|
|
32
|
+
| `--logLevel=<silent\|info\|verbose>` | | Specify build-time log level |
|
|
33
|
+
| `--force` | `false` | Force override file if it already exists |
|
|
34
34
|
<!--/add-opts-->
|
|
35
35
|
|
|
36
36
|
**Modifiers:**
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "nuxt analyze"
|
|
3
|
+
description: "Analyze the production bundle or your Nuxt application."
|
|
4
|
+
links:
|
|
5
|
+
- label: Source
|
|
6
|
+
icon: i-simple-icons-github
|
|
7
|
+
to: https://github.com/nuxt/cli/blob/main/packages/nuxi/src/commands/analyze.ts
|
|
8
|
+
size: xs
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
<!--analyze-cmd-->
|
|
12
|
+
```bash [Terminal]
|
|
13
|
+
npx nuxt analyze [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--dotenv] [-e, --extends=<layer-name>] [--name=<name>] [--no-serve]
|
|
14
|
+
```
|
|
15
|
+
<!--/analyze-cmd-->
|
|
16
|
+
|
|
17
|
+
The `analyze` command builds Nuxt and analyzes the production bundle (experimental).
|
|
18
|
+
|
|
19
|
+
## Arguments
|
|
20
|
+
|
|
21
|
+
<!--analyze-args-->
|
|
22
|
+
| Argument | Description |
|
|
23
|
+
|---------------|------------------------------------------------|
|
|
24
|
+
| `ROOTDIR="."` | Specifies the working directory (default: `.`) |
|
|
25
|
+
<!--/analyze-args-->
|
|
26
|
+
|
|
27
|
+
## Options
|
|
28
|
+
|
|
29
|
+
<!--analyze-opts-->
|
|
30
|
+
| Option | Default | Description |
|
|
31
|
+
|--------------------------------------|-----------|----------------------------------------------------------------------------------|
|
|
32
|
+
| `--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`) |
|
|
33
|
+
| `--logLevel=<silent\|info\|verbose>` | | Specify build-time log level |
|
|
34
|
+
| `--dotenv` | | Path to `.env` file to load, relative to the root directory |
|
|
35
|
+
| `-e, --extends=<layer-name>` | | Extend from a Nuxt layer |
|
|
36
|
+
| `--name=<name>` | `default` | Name of the analysis |
|
|
37
|
+
| `--no-serve` | | Skip serving the analysis results |
|
|
38
|
+
<!--/analyze-opts-->
|
|
39
|
+
|
|
40
|
+
::note
|
|
41
|
+
This command sets `process.env.NODE_ENV` to `production`.
|
|
42
|
+
::
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'nuxt build-module'
|
|
3
|
+
description: 'Nuxt command to build your Nuxt module before publishing.'
|
|
4
|
+
links:
|
|
5
|
+
- label: Source
|
|
6
|
+
icon: i-simple-icons-github
|
|
7
|
+
to: https://github.com/nuxt/module-builder/blob/main/src/cli.ts
|
|
8
|
+
size: xs
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
<!--build-module-cmd-->
|
|
12
|
+
```bash [Terminal]
|
|
13
|
+
npx nuxt build-module [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--build] [--stub] [--sourcemap] [--prepare]
|
|
14
|
+
```
|
|
15
|
+
<!--/build-module-cmd-->
|
|
16
|
+
|
|
17
|
+
The `build-module` command runs `@nuxt/module-builder` to generate `dist` directory within your `rootDir` that contains the full build for your **nuxt-module**.
|
|
18
|
+
|
|
19
|
+
## Arguments
|
|
20
|
+
|
|
21
|
+
<!--build-module-args-->
|
|
22
|
+
| Argument | Description |
|
|
23
|
+
|---------------|------------------------------------------------|
|
|
24
|
+
| `ROOTDIR="."` | Specifies the working directory (default: `.`) |
|
|
25
|
+
<!--/build-module-args-->
|
|
26
|
+
|
|
27
|
+
## Options
|
|
28
|
+
|
|
29
|
+
<!--build-module-opts-->
|
|
30
|
+
| Option | Default | Description |
|
|
31
|
+
|--------------------------------------|---------|----------------------------------------------------------------------------------|
|
|
32
|
+
| `--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`) |
|
|
33
|
+
| `--logLevel=<silent\|info\|verbose>` | | Specify build-time log level |
|
|
34
|
+
| `--build` | `false` | Build module for distribution |
|
|
35
|
+
| `--stub` | `false` | Stub dist instead of actually building it for development |
|
|
36
|
+
| `--sourcemap` | `false` | Generate sourcemaps |
|
|
37
|
+
| `--prepare` | `false` | Prepare module for local development |
|
|
38
|
+
<!--/build-module-opts-->
|
|
39
|
+
|
|
40
|
+
::read-more{to="https://github.com/nuxt/module-builder" icon="i-simple-icons-github" target="\_blank"}
|
|
41
|
+
Read more about `@nuxt/module-builder`.
|
|
42
|
+
::
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "nuxt build"
|
|
3
|
+
description: "Build your Nuxt application."
|
|
4
|
+
links:
|
|
5
|
+
- label: Source
|
|
6
|
+
icon: i-simple-icons-github
|
|
7
|
+
to: https://github.com/nuxt/cli/blob/main/packages/nuxi/src/commands/build.ts
|
|
8
|
+
size: xs
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
<!--build-cmd-->
|
|
12
|
+
```bash [Terminal]
|
|
13
|
+
npx nuxt build [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--prerender] [--preset] [--dotenv] [--envName] [-e, --extends=<layer-name>]
|
|
14
|
+
```
|
|
15
|
+
<!--/build-cmd-->
|
|
16
|
+
|
|
17
|
+
The `build` command creates a `.output` directory with all your application, server and dependencies ready for production.
|
|
18
|
+
|
|
19
|
+
## Arguments
|
|
20
|
+
|
|
21
|
+
<!--build-args-->
|
|
22
|
+
| Argument | Description |
|
|
23
|
+
|---------------|------------------------------------------------|
|
|
24
|
+
| `ROOTDIR="."` | Specifies the working directory (default: `.`) |
|
|
25
|
+
<!--/build-args-->
|
|
26
|
+
|
|
27
|
+
## Options
|
|
28
|
+
|
|
29
|
+
<!--build-opts-->
|
|
30
|
+
| Option | Default | Description |
|
|
31
|
+
|--------------------------------------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
32
|
+
| `--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`) |
|
|
33
|
+
| `--logLevel=<silent\|info\|verbose>` | | Specify build-time log level |
|
|
34
|
+
| `--prerender` | | Build Nuxt and prerender static routes |
|
|
35
|
+
| `--preset` | | Nitro server preset |
|
|
36
|
+
| `--dotenv` | | Path to `.env` file to load, relative to the root directory |
|
|
37
|
+
| `--envName` | | The environment to use when resolving configuration overrides (default is `production` when building, and `development` when running the dev server) |
|
|
38
|
+
| `-e, --extends=<layer-name>` | | Extend from a Nuxt layer |
|
|
39
|
+
<!--/build-opts-->
|
|
40
|
+
|
|
41
|
+
::note
|
|
42
|
+
This command sets `process.env.NODE_ENV` to `production`.
|
|
43
|
+
::
|
|
44
|
+
|
|
45
|
+
::note
|
|
46
|
+
`--prerender` will always set the `preset` to `static`
|
|
47
|
+
::
|