@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
|
@@ -117,7 +117,7 @@ Nuxt Modules come with a variety of powerful APIs and patterns allowing them to
|
|
|
117
117
|
We can consider two kinds of Nuxt Modules:
|
|
118
118
|
|
|
119
119
|
- published modules are distributed on npm - you can see a list of some community modules on [the Nuxt website](/modules).
|
|
120
|
-
- "local" modules, they exist within a Nuxt project itself, either [inlined in Nuxt config](/docs/4.x/api/nuxt-config#modules) or as part of [the `modules` directory](/docs/4.x/
|
|
120
|
+
- "local" modules, they exist within a Nuxt project itself, either [inlined in Nuxt config](/docs/4.x/api/nuxt-config#modules) or as part of [the `modules` directory](/docs/4.x/directory-structure/modules).
|
|
121
121
|
|
|
122
122
|
In either case, their anatomy is similar.
|
|
123
123
|
|
|
@@ -224,7 +224,7 @@ Modules, like everything in a Nuxt configuration, aren't included in your applic
|
|
|
224
224
|
Inside the runtime directory, you can provide any kind of assets related to the Nuxt App:
|
|
225
225
|
- Vue components
|
|
226
226
|
- Composables
|
|
227
|
-
- [Nuxt plugins](/docs/4.x/
|
|
227
|
+
- [Nuxt plugins](/docs/4.x/directory-structure/app/plugins)
|
|
228
228
|
|
|
229
229
|
To the [server engine](/docs/4.x/guide/concepts/server-engine), Nitro:
|
|
230
230
|
- API routes
|
|
@@ -653,6 +653,19 @@ export default defineNuxtModule({
|
|
|
653
653
|
})
|
|
654
654
|
```
|
|
655
655
|
|
|
656
|
+
#### Updating Templates
|
|
657
|
+
|
|
658
|
+
If you need to update your templates/virtual files, you can leverage the `updateTemplates` utility like this:
|
|
659
|
+
|
|
660
|
+
```ts
|
|
661
|
+
nuxt.hook('builder:watch', (event, path) => {
|
|
662
|
+
if (path.includes('my-module-feature.config')) {
|
|
663
|
+
// This will reload the template that you registered
|
|
664
|
+
updateTemplates({ filter: t => t.filename === 'my-module-feature.mjs' })
|
|
665
|
+
}
|
|
666
|
+
})
|
|
667
|
+
```
|
|
668
|
+
|
|
656
669
|
#### Adding Type Declarations
|
|
657
670
|
|
|
658
671
|
You might also want to add a type declaration to the user's project (for example, to augment a Nuxt interface
|
|
@@ -691,19 +704,73 @@ nuxt.hook('prepare:types', ({ references }) => {
|
|
|
691
704
|
})
|
|
692
705
|
```
|
|
693
706
|
|
|
694
|
-
|
|
707
|
+
#### Extending `tsconfig.json`
|
|
708
|
+
|
|
709
|
+
There are multiple ways to extend the TypeScript configuration of the user's project from your module.
|
|
695
710
|
|
|
696
|
-
|
|
711
|
+
The simplest way is to modify the Nuxt configuration directly like this:
|
|
697
712
|
|
|
713
|
+
<!-- @case-police-ignore tsConfig -->
|
|
698
714
|
```ts
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
715
|
+
// extend tsconfig.app.json
|
|
716
|
+
nuxt.options.typescript.tsConfig.include ??= []
|
|
717
|
+
nuxt.options.typescript.tsConfig.include.push(resolve('./augments.d.ts'))
|
|
718
|
+
|
|
719
|
+
// extend tsconfig.shared.json
|
|
720
|
+
nuxt.options.typescript.sharedTsConfig.include ??= []
|
|
721
|
+
nuxt.options.typescript.sharedTsConfig.include.push(resolve('./augments.d.ts'))
|
|
722
|
+
|
|
723
|
+
// extend tsconfig.node.json
|
|
724
|
+
nuxt.options.typescript.nodeTsConfig.include ??= []
|
|
725
|
+
nuxt.options.typescript.nodeTsConfig.include.push(resolve('./augments.d.ts'))
|
|
726
|
+
|
|
727
|
+
// extend tsconfig.server.json
|
|
728
|
+
nuxt.options.nitro.typescript ??= {}
|
|
729
|
+
nuxt.options.nitro.typescript.tsConfig ??= {}
|
|
730
|
+
nuxt.options.nitro.typescript.tsConfig.include ??= []
|
|
731
|
+
nuxt.options.nitro.typescript.tsConfig.include.push(resolve('./augments.d.ts'))
|
|
732
|
+
```
|
|
733
|
+
|
|
734
|
+
Alternatively, you can use the `prepare:types` and `nitro:prepare:types` hooks to extend the TypeScript references for specific type contexts, or modify the TypeScript configuration similar to the example above.
|
|
735
|
+
|
|
736
|
+
```ts
|
|
737
|
+
nuxt.hook('prepare:types', ({ references, sharedReferences, nodeReferences }) => {
|
|
738
|
+
// extend app context
|
|
739
|
+
references.push({ path: resolve('./augments.d.ts') })
|
|
740
|
+
// extend shared context
|
|
741
|
+
sharedReferences.push({ path: resolve('./augments.d.ts') })
|
|
742
|
+
// extend node context
|
|
743
|
+
nodeReferences.push({ path: resolve('./augments.d.ts') })
|
|
744
|
+
})
|
|
745
|
+
|
|
746
|
+
nuxt.hook('nitro:prepare:types', ({ references }) => {
|
|
747
|
+
// extend server context
|
|
748
|
+
references.push({ path: resolve('./augments.d.ts') })
|
|
704
749
|
})
|
|
705
750
|
```
|
|
706
751
|
|
|
752
|
+
::note
|
|
753
|
+
TypeScript references add files to the type context [without being affected by the `exclude` option in `tsconfig.json`](https://www.typescriptlang.org/tsconfig/#exclude).
|
|
754
|
+
::
|
|
755
|
+
|
|
756
|
+
#### Augmenting Types From Modules
|
|
757
|
+
|
|
758
|
+
Nuxt automatically includes your module's directories in the appropriate type contexts. To augment types from your module, all you need to do is place the type declaration file in the appropriate directory based on the augmented type context. Alternatively, you can [extend the TypeScript configuration](/docs/4.x/guide/going-further/modules#extending-tsconfigjson) to augment from an arbitrary location.
|
|
759
|
+
|
|
760
|
+
- `my-module/runtime/` - app type context (except for the `runtime/server` directory)
|
|
761
|
+
- `my-module/runtime/server/` - server type context
|
|
762
|
+
- `my-module/` - node type context (except for the `runtime/` and `runtime/server` directories)
|
|
763
|
+
|
|
764
|
+
```bash [Directory Structure]
|
|
765
|
+
-| my-module/ # node type context
|
|
766
|
+
---| runtime/ # app type context
|
|
767
|
+
------| augments.app.d.ts
|
|
768
|
+
------| server/ # server type context
|
|
769
|
+
---------| augments.server.d.ts
|
|
770
|
+
---| module.ts
|
|
771
|
+
---| augments.node.d.ts
|
|
772
|
+
```
|
|
773
|
+
|
|
707
774
|
### Testing
|
|
708
775
|
|
|
709
776
|
Testing helps ensuring your module works as expected given various setup. Find in this section how to perform various kinds of tests against your module.
|
|
@@ -774,7 +841,7 @@ An example of such a workflow is available on [the module starter](https://githu
|
|
|
774
841
|
|
|
775
842
|
Having a playground Nuxt application to test your module when developing it is really useful. [The module starter integrates one for that purpose](/docs/4.x/guide/going-further/modules#how-to-develop).
|
|
776
843
|
|
|
777
|
-
You can test your module with other Nuxt applications (applications that are not part of your module repository) locally. To do so, you can use [`npm pack`](https://docs.npmjs.com/cli/commands/npm-pack) command, or your package manager equivalent, to create a tarball from your module. Then in your test project, you can add your module to `package.json` packages as: `"my-module": "file:/path/to/tarball.tgz"`.
|
|
844
|
+
You can test your module with other Nuxt applications (applications that are not part of your module repository) locally. To do so, you can use [`npm pack`](https://docs.npmjs.com/cli/commands/npm-pack/) command, or your package manager equivalent, to create a tarball from your module. Then in your test project, you can add your module to `package.json` packages as: `"my-module": "file:/path/to/tarball.tgz"`.
|
|
778
845
|
|
|
779
846
|
After that, you should be able to reference `my-module` like in any regular project.
|
|
780
847
|
|
|
@@ -876,7 +943,7 @@ Watch Vue School video about Nuxt module types.
|
|
|
876
943
|
|
|
877
944
|
### Module Types
|
|
878
945
|
|
|
879
|
-
**Official modules** are modules prefixed (scoped) with `@nuxt/` (e.g. [`@nuxt/content`](https://content.
|
|
946
|
+
**Official modules** are modules prefixed (scoped) with `@nuxt/` (e.g. [`@nuxt/content`](https://content.nuxt.com)). They are made and maintained actively by the Nuxt team. Like with the framework, contributions from the community are more than welcome to help make them better!
|
|
880
947
|
|
|
881
948
|
**Community modules** are modules prefixed (scoped) with `@nuxtjs/` (e.g. [`@nuxtjs/tailwindcss`](https://tailwindcss.nuxtjs.org)). They are proven modules made and maintained by community members. Again, contributions are welcome from anyone.
|
|
882
949
|
|
|
@@ -9,7 +9,7 @@ links:
|
|
|
9
9
|
|
|
10
10
|
In Nuxt, you can access runtime app context within composables, components and plugins.
|
|
11
11
|
|
|
12
|
-
::read-more{to="https://v2.nuxt.com/docs/internals-glossary/context
|
|
12
|
+
::read-more{to="https://v2.nuxt.com/docs/internals-glossary/context/#the-context" target="_blank"}
|
|
13
13
|
In Nuxt 2, this was referred to as **Nuxt context**.
|
|
14
14
|
::
|
|
15
15
|
|
|
@@ -23,7 +23,7 @@ Jump over the `NuxtApp` interface documentation.
|
|
|
23
23
|
|
|
24
24
|
Many composables and utilities, both built-in and user-made, may require access to the Nuxt instance. This doesn't exist everywhere on your application, because a fresh instance is created on every request.
|
|
25
25
|
|
|
26
|
-
Currently, the Nuxt context is only accessible in [plugins](/docs/4.x/
|
|
26
|
+
Currently, the Nuxt context is only accessible in [plugins](/docs/4.x/directory-structure/app/plugins), [Nuxt hooks](/docs/4.x/guide/going-further/hooks), [Nuxt middleware](/docs/4.x/directory-structure/app/middleware) (if wrapped in `defineNuxtRouteMiddleware`), and [setup functions](https://vuejs.org/api/composition-api-setup) (in pages and components).
|
|
27
27
|
|
|
28
28
|
If a composable is called without access to the context, you may get an error stating that 'A composable that requires access to the Nuxt instance was called outside of a plugin, Nuxt hook, Nuxt middleware, or Vue setup function.' In that case, you can also explicitly call functions within this context by using [`nuxtApp.runWithContext`](/docs/4.x/api/composables/use-nuxt-app#runwithcontext).
|
|
29
29
|
|
|
@@ -42,7 +42,7 @@ If your composable does not always need `nuxtApp` or you simply want to check if
|
|
|
42
42
|
|
|
43
43
|
Plugins also receive `nuxtApp` as the first argument for convenience.
|
|
44
44
|
|
|
45
|
-
:read-more{to="/docs/4.x/
|
|
45
|
+
:read-more{to="/docs/4.x/directory-structure/app/plugins"}
|
|
46
46
|
|
|
47
47
|
## Providing Helpers
|
|
48
48
|
|
|
@@ -55,10 +55,10 @@ nuxtApp.provide('hello', name => `Hello ${name}!`)
|
|
|
55
55
|
console.log(nuxtApp.$hello('name')) // Prints "Hello name!"
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
::read-more{to="/docs/4.x/
|
|
58
|
+
::read-more{to="/docs/4.x/directory-structure/app/plugins#providing-helpers"}
|
|
59
59
|
It is possible to inject helpers by returning an object with a `provide` key in plugins.
|
|
60
60
|
::
|
|
61
61
|
|
|
62
|
-
::read-more{to="https://v2.nuxt.com/docs/directory-structure/plugins
|
|
62
|
+
::read-more{to="https://v2.nuxt.com/docs/directory-structure/plugins/#inject-in-root--context" target="_blank"}
|
|
63
63
|
In Nuxt 2 plugins, this was referred to as **inject function**.
|
|
64
64
|
::
|
|
@@ -7,7 +7,7 @@ Nuxt layers are a powerful feature that you can use to share and reuse partial N
|
|
|
7
7
|
|
|
8
8
|
:read-more{to="/docs/4.x/getting-started/layers"}
|
|
9
9
|
|
|
10
|
-
A minimal Nuxt layer directory should contain a [`nuxt.config.ts`](/docs/4.x/
|
|
10
|
+
A minimal Nuxt layer directory should contain a [`nuxt.config.ts`](/docs/4.x/directory-structure/nuxt-config) file to indicate it is a layer.
|
|
11
11
|
|
|
12
12
|
```ts [base/nuxt.config.ts]
|
|
13
13
|
export default defineNuxtConfig({})
|
|
@@ -15,20 +15,20 @@ export default defineNuxtConfig({})
|
|
|
15
15
|
|
|
16
16
|
Additionally, certain other files in the layer directory will be auto-scanned and used by Nuxt for the project extending this layer.
|
|
17
17
|
|
|
18
|
-
- [`app/components/*`](/docs/4.x/
|
|
19
|
-
- [`app/composables/*`](/docs/4.x/
|
|
20
|
-
- [`app/layouts/*`](/docs/4.x/
|
|
21
|
-
- [`app/middleware/*`](/docs/4.x/
|
|
22
|
-
- [`app/pages/*`](/docs/4.x/
|
|
23
|
-
- [`app/plugins/*`](/docs/4.x/
|
|
24
|
-
- [`app/utils/*`](/docs/4.x/
|
|
25
|
-
- [`app/app.config.ts`](/docs/4.x/
|
|
26
|
-
- [`server/*`](/docs/4.x/
|
|
27
|
-
- [`nuxt.config.ts`](/docs/4.x/
|
|
18
|
+
- [`app/components/*`](/docs/4.x/directory-structure/app/components) - Extend the default components
|
|
19
|
+
- [`app/composables/*`](/docs/4.x/directory-structure/app/composables) - Extend the default composables
|
|
20
|
+
- [`app/layouts/*`](/docs/4.x/directory-structure/app/layouts) - Extend the default layouts
|
|
21
|
+
- [`app/middleware/*`](/docs/4.x/directory-structure/app/middleware) - Extend the default middleware
|
|
22
|
+
- [`app/pages/*`](/docs/4.x/directory-structure/app/pages) - Extend the default pages
|
|
23
|
+
- [`app/plugins/*`](/docs/4.x/directory-structure/app/plugins) - Extend the default plugins
|
|
24
|
+
- [`app/utils/*`](/docs/4.x/directory-structure/app/utils) - Extend the default utils
|
|
25
|
+
- [`app/app.config.ts`](/docs/4.x/directory-structure/app/app-config) - Extend the default app config
|
|
26
|
+
- [`server/*`](/docs/4.x/directory-structure/server) - Extend the default server endpoints & middleware
|
|
27
|
+
- [`nuxt.config.ts`](/docs/4.x/directory-structure/nuxt-config)- Extend the default nuxt config
|
|
28
28
|
|
|
29
29
|
## Basic Example
|
|
30
30
|
|
|
31
|
-
::code-
|
|
31
|
+
::code-tree{defaultValue="nuxt.config.ts" expandAll}
|
|
32
32
|
|
|
33
33
|
```ts [nuxt.config.ts]
|
|
34
34
|
export default defineNuxtConfig({
|
|
@@ -68,29 +68,46 @@ Additionally, certain other files in the layer directory will be auto-scanned an
|
|
|
68
68
|
|
|
69
69
|
## Layer Priority
|
|
70
70
|
|
|
71
|
-
When extending from multiple layers, it's important to understand the priority
|
|
71
|
+
When extending from multiple layers, it's important to understand the override order. Layers with **higher priority** override layers with lower priority when they define the same files or components.
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
2. **Auto-scanned local layers** from `~~/layers` directory in alphabetical order (Z overrides A)
|
|
75
|
-
3. **Your project** has the highest priority in the stack - it will always override other layers
|
|
73
|
+
The priority order from highest to lowest is:
|
|
76
74
|
|
|
77
|
-
|
|
75
|
+
1. **Your project files** - always have the highest priority
|
|
76
|
+
2. **Auto-scanned layers** from `~~/layers` directory - sorted alphabetically (Z has higher priority than A)
|
|
77
|
+
3. **Layers in `extends`** config - first entry has higher priority than second
|
|
78
|
+
|
|
79
|
+
### When to Use Each
|
|
80
|
+
|
|
81
|
+
- **`extends`** - Use for external dependencies (npm packages, remote repositories) or layers outside your project directory
|
|
82
|
+
- **`~~/layers` directory** - Use for local layers that are part of your project
|
|
83
|
+
|
|
84
|
+
::tip
|
|
85
|
+
If you need to control the order of auto-scanned layers, you can prefix them with numbers: `~/layers/1.z-layer`, `~/layers/2.a-layer`. This way `2.a-layer` will have higher priority than `1.z-layer`.
|
|
86
|
+
::
|
|
87
|
+
|
|
88
|
+
### Example
|
|
78
89
|
|
|
79
90
|
```ts [nuxt.config.ts]
|
|
80
91
|
export default defineNuxtConfig({
|
|
81
92
|
extends: [
|
|
82
|
-
//
|
|
83
|
-
'
|
|
84
|
-
//
|
|
85
|
-
'
|
|
86
|
-
//
|
|
87
|
-
'
|
|
93
|
+
// Local layer outside the project
|
|
94
|
+
'../base',
|
|
95
|
+
// NPM package
|
|
96
|
+
'@my-themes/awesome',
|
|
97
|
+
// Remote repository
|
|
98
|
+
'github:my-themes/awesome#v1',
|
|
88
99
|
],
|
|
89
|
-
// Your project has the highest priority
|
|
90
100
|
})
|
|
91
101
|
```
|
|
92
102
|
|
|
93
|
-
If you also have
|
|
103
|
+
If you also have `~~/layers/custom`, the priority order is:
|
|
104
|
+
- Your project files (highest)
|
|
105
|
+
- `~~/layers/custom`
|
|
106
|
+
- `../base`
|
|
107
|
+
- `@my-themes/awesome`
|
|
108
|
+
- `github:my-themes/awesome#v1` (lowest)
|
|
109
|
+
|
|
110
|
+
This means your project files will override any layer, and `~~/layers/custom` will override anything in `extends`.
|
|
94
111
|
|
|
95
112
|
## Starter Template
|
|
96
113
|
|
|
@@ -36,7 +36,7 @@ It is possible to debug your Nuxt app in your IDE while you are developing it.
|
|
|
36
36
|
|
|
37
37
|
### Example VS Code Debug Configuration
|
|
38
38
|
|
|
39
|
-
You may need to update the config below with a path to your web browser. For more information, visit the [VS Code documentation about debug configuration](https://
|
|
39
|
+
You may need to update the config below with a path to your web browser. For more information, visit the [VS Code documentation about debug configuration](https://code.visualstudio.com/docs/debugtest/debugging#_launch-configurations).
|
|
40
40
|
|
|
41
41
|
```json5
|
|
42
42
|
{
|
|
@@ -12,7 +12,7 @@ links:
|
|
|
12
12
|
|
|
13
13
|
Usage of `<NuxtPicture>` is almost identical to [`<NuxtImg>`](/docs/4.x/api/components/nuxt-img) but it also allows serving modern formats like `webp` when possible.
|
|
14
14
|
|
|
15
|
-
Learn more about the [`<picture>` tag on MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/
|
|
15
|
+
Learn more about the [`<picture>` tag on MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/picture).
|
|
16
16
|
|
|
17
17
|
## Setup
|
|
18
18
|
|
|
@@ -4,7 +4,7 @@ description: The <Teleport> component teleports a component to a different locat
|
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
::warning
|
|
7
|
-
The `to` target of [`<Teleport>`](https://vuejs.org/guide/built-ins/teleport
|
|
7
|
+
The `to` target of [`<Teleport>`](https://vuejs.org/guide/built-ins/teleport) expects a CSS selector string or an actual DOM node. Nuxt currently has SSR support for teleports to `#teleports` only, with client-side support for other targets using a `<ClientOnly>` wrapper.
|
|
8
8
|
::
|
|
9
9
|
|
|
10
10
|
## Body Teleport
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: '<NuxtRouteAnnouncer>'
|
|
3
3
|
description: 'The <NuxtRouteAnnouncer> component adds a hidden element with the page title to announce route changes to assistive technologies.'
|
|
4
|
-
navigation:
|
|
5
|
-
badge: New
|
|
6
4
|
links:
|
|
7
5
|
- label: Source
|
|
8
6
|
icon: i-simple-icons-github
|
|
@@ -16,7 +14,7 @@ This component is available in Nuxt v3.12+.
|
|
|
16
14
|
|
|
17
15
|
## Usage
|
|
18
16
|
|
|
19
|
-
Add `<NuxtRouteAnnouncer/>` in your [`app.vue`](/docs/4.x/
|
|
17
|
+
Add `<NuxtRouteAnnouncer/>` in your [`app.vue`](/docs/4.x/directory-structure/app/app) or [`app/layouts/`](/docs/4.x/directory-structure/app/layouts) to enhance accessibility by informing assistive technologies about page title changes. This ensures that navigational changes are announced to users relying on screen readers.
|
|
20
18
|
|
|
21
19
|
```vue [app/app.vue]
|
|
22
20
|
<template>
|
|
@@ -8,10 +8,10 @@ links:
|
|
|
8
8
|
size: xs
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
`<NuxtPage>` is a built-in component that comes with Nuxt. It lets you display top-level or nested pages located in the [`app/pages/`](/docs/4.x/
|
|
11
|
+
`<NuxtPage>` is a built-in component that comes with Nuxt. It lets you display top-level or nested pages located in the [`app/pages/`](/docs/4.x/directory-structure/app/pages) directory.
|
|
12
12
|
|
|
13
13
|
::note
|
|
14
|
-
`<NuxtPage>` is a wrapper around [`<RouterView>`](https://router.vuejs.org/api/interfaces/
|
|
14
|
+
`<NuxtPage>` is a wrapper around [`<RouterView>`](https://router.vuejs.org/api/interfaces/routerviewprops) from Vue Router. It should be used instead of `<RouterView>` because the former takes additional care of internal states. Otherwise, `useRoute()` may return incorrect paths.
|
|
15
15
|
::
|
|
16
16
|
|
|
17
17
|
`<NuxtPage>` includes the following components:
|
|
@@ -151,4 +151,4 @@ console.log(attrs.foobar) // Outputs: 123
|
|
|
151
151
|
</script>
|
|
152
152
|
```
|
|
153
153
|
|
|
154
|
-
:read-more{to="/docs/4.x/
|
|
154
|
+
:read-more{to="/docs/4.x/directory-structure/app/pages"}
|
|
@@ -18,11 +18,11 @@ You can use `<NuxtLayout />` component to activate the `default` layout on `app.
|
|
|
18
18
|
</template>
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
:read-more{to="/docs/4.x/
|
|
21
|
+
:read-more{to="/docs/4.x/directory-structure/app/layouts"}
|
|
22
22
|
|
|
23
23
|
## Props
|
|
24
24
|
|
|
25
|
-
- `name`: Specify a layout name to be rendered, can be a string, reactive reference or a computed property. It **must** match the name of the corresponding layout file in the [`app/layouts/`](/docs/4.x/
|
|
25
|
+
- `name`: Specify a layout name to be rendered, can be a string, reactive reference or a computed property. It **must** match the name of the corresponding layout file in the [`app/layouts/`](/docs/4.x/directory-structure/app/layouts) directory.
|
|
26
26
|
- **type**: `string`
|
|
27
27
|
- **default**: `default`
|
|
28
28
|
|
|
@@ -51,11 +51,11 @@ Please note the layout name is normalized to kebab-case, so if your layout file
|
|
|
51
51
|
</template>
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
::read-more{to="/docs/4.x/
|
|
54
|
+
::read-more{to="/docs/4.x/directory-structure/app/layouts"}
|
|
55
55
|
Read more about dynamic layouts.
|
|
56
56
|
::
|
|
57
57
|
|
|
58
|
-
- `fallback`: If an invalid layout is passed to the `name` prop, no layout will be rendered. Specify a `fallback` layout to be rendered in this scenario. It **must** match the name of the corresponding layout file in the [`app/layouts/`](/docs/4.x/
|
|
58
|
+
- `fallback`: If an invalid layout is passed to the `name` prop, no layout will be rendered. Specify a `fallback` layout to be rendered in this scenario. It **must** match the name of the corresponding layout file in the [`app/layouts/`](/docs/4.x/directory-structure/app/layouts) directory.
|
|
59
59
|
- **type**: `string`
|
|
60
60
|
- **default**: `null`
|
|
61
61
|
|
|
@@ -158,4 +158,4 @@ defineExpose({
|
|
|
158
158
|
|
|
159
159
|
::
|
|
160
160
|
|
|
161
|
-
:read-more{to="/docs/4.x/
|
|
161
|
+
:read-more{to="/docs/4.x/directory-structure/app/layouts"}
|
|
@@ -244,21 +244,21 @@ export default defineNuxtConfig({
|
|
|
244
244
|
|
|
245
245
|
### RouterLink
|
|
246
246
|
|
|
247
|
-
When not using `external`, `<NuxtLink>` supports all Vue Router's [`RouterLink` props](https://router.vuejs.org/api/interfaces/
|
|
247
|
+
When not using `external`, `<NuxtLink>` supports all Vue Router's [`RouterLink` props](https://router.vuejs.org/api/interfaces/routerlinkprops)
|
|
248
248
|
|
|
249
|
-
- `to`: Any URL or a [route location object](https://router.vuejs.org/api/type-aliases/
|
|
250
|
-
- `custom`: Whether `<NuxtLink>` should wrap its content in an `<a>` element. It allows taking full control of how a link is rendered and how navigation works when it is clicked. Works the same as [Vue Router's `custom` prop](https://router.vuejs.org/api/interfaces/
|
|
251
|
-
- `exactActiveClass`: A class to apply on exact active links. Works the same as [Vue Router's `exactActiveClass` prop](https://router.vuejs.org/api/interfaces/
|
|
252
|
-
- `activeClass`: A class to apply on active links. Works the same as [Vue Router's `activeClass` prop](https://router.vuejs.org/api/interfaces/
|
|
253
|
-
- `replace`: Works the same as [Vue Router's `replace` prop](https://router.vuejs.org/api/interfaces/
|
|
254
|
-
- `ariaCurrentValue`: An `aria-current` attribute value to apply on exact active links. Works the same as [Vue Router's `ariaCurrentValue` prop](https://router.vuejs.org/api/interfaces/
|
|
249
|
+
- `to`: Any URL or a [route location object](https://router.vuejs.org/api/type-aliases/routelocation) from Vue Router
|
|
250
|
+
- `custom`: Whether `<NuxtLink>` should wrap its content in an `<a>` element. It allows taking full control of how a link is rendered and how navigation works when it is clicked. Works the same as [Vue Router's `custom` prop](https://router.vuejs.org/api/interfaces/routerlinkprops#custom-)
|
|
251
|
+
- `exactActiveClass`: A class to apply on exact active links. Works the same as [Vue Router's `exactActiveClass` prop](https://router.vuejs.org/api/interfaces/routerlinkprops#exactActiveClass-) on internal links. Defaults to Vue Router's default (`"router-link-exact-active"`)
|
|
252
|
+
- `activeClass`: A class to apply on active links. Works the same as [Vue Router's `activeClass` prop](https://router.vuejs.org/api/interfaces/routerlinkprops#activeClass-) on internal links. Defaults to Vue Router's default (`"router-link-active"`)
|
|
253
|
+
- `replace`: Works the same as [Vue Router's `replace` prop](https://router.vuejs.org/api/interfaces/routelocationoptions#replace-) on internal links
|
|
254
|
+
- `ariaCurrentValue`: An `aria-current` attribute value to apply on exact active links. Works the same as [Vue Router's `ariaCurrentValue` prop](https://router.vuejs.org/api/interfaces/routerlinkprops#ariaCurrentValue-) on internal links
|
|
255
255
|
|
|
256
256
|
### NuxtLink
|
|
257
257
|
|
|
258
258
|
- `href`: An alias for `to`. If used with `to`, `href` will be ignored
|
|
259
259
|
- `noRel`: If set to `true`, no `rel` attribute will be added to the external link
|
|
260
260
|
- `external`: Forces the link to be rendered as an `<a>` tag instead of a Vue Router `RouterLink`.
|
|
261
|
-
- `prefetch`: When enabled will prefetch middleware, layouts and payloads (when using [payloadExtraction](/docs/4.x/
|
|
261
|
+
- `prefetch`: When enabled will prefetch middleware, layouts and payloads (when using [payloadExtraction](/docs/4.x/guide/going-further/experimental-features#payloadextraction)) of links in the viewport. Used by the experimental [crossOriginPrefetch](/docs/4.x/guide/going-further/experimental-features#crossoriginprefetch) config.
|
|
262
262
|
- `prefetchOn`: Allows custom control of when to prefetch links. Possible options are `interaction` and `visibility` (default). You can also pass an object for full control, for example: `{ interaction: true, visibility: true }`. This prop is only used when `prefetch` is enabled (default) and `noPrefetch` is not set.
|
|
263
263
|
- `noPrefetch`: Disables prefetching.
|
|
264
264
|
- `prefetchedClass`: A class to apply to links that have been prefetched.
|
|
@@ -276,7 +276,7 @@ Defaults can be overwritten, see [overwriting defaults](/docs/4.x/api/components
|
|
|
276
276
|
|
|
277
277
|
### In Nuxt Config
|
|
278
278
|
|
|
279
|
-
You can overwrite some `<NuxtLink>` defaults in your [`nuxt.config`](/docs/4.x/
|
|
279
|
+
You can overwrite some `<NuxtLink>` defaults in your [`nuxt.config`](/docs/4.x/guide/going-further/experimental-features#defaults)
|
|
280
280
|
|
|
281
281
|
::important
|
|
282
282
|
These options will likely be moved elsewhere in the future, such as into `app.config` or into the `app/` directory.
|
|
@@ -336,8 +336,8 @@ function defineNuxtLink (options: NuxtLinkOptions): Component {}
|
|
|
336
336
|
|
|
337
337
|
- `componentName`: A name for the component. Default is `NuxtLink`.
|
|
338
338
|
- `externalRelAttribute`: A default `rel` attribute value applied on external links. Defaults to `"noopener noreferrer"`. Set it to `""` to disable
|
|
339
|
-
- `activeClass`: A default class to apply on active links. Works the same as [Vue Router's `linkActiveClass` option](https://router.vuejs.org/api/interfaces/
|
|
340
|
-
- `exactActiveClass`: A default class to apply on exact active links. Works the same as [Vue Router's `linkExactActiveClass` option](https://router.vuejs.org/api/interfaces/
|
|
339
|
+
- `activeClass`: A default class to apply on active links. Works the same as [Vue Router's `linkActiveClass` option](https://router.vuejs.org/api/interfaces/routeroptions#linkActiveClass-). Defaults to Vue Router's default (`"router-link-active"`)
|
|
340
|
+
- `exactActiveClass`: A default class to apply on exact active links. Works the same as [Vue Router's `linkExactActiveClass` option](https://router.vuejs.org/api/interfaces/routeroptions#linkExactActiveClass-). Defaults to Vue Router's default (`"router-link-exact-active"`)
|
|
341
341
|
- `trailingSlash`: An option to either add or remove trailing slashes in the `href`. If unset or not matching the valid values `append` or `remove`, it will be ignored.
|
|
342
342
|
- `prefetch`: Whether or not to prefetch links by default.
|
|
343
343
|
- `prefetchOn`: Granular control of which prefetch strategies to apply by default.
|
|
@@ -10,7 +10,7 @@ links:
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
Add `<NuxtLoadingIndicator/>` in your [`app.vue`](/docs/4.x/
|
|
13
|
+
Add `<NuxtLoadingIndicator/>` in your [`app.vue`](/docs/4.x/directory-structure/app/app) or [`app/layouts/`](/docs/4.x/directory-structure/app/layouts).
|
|
14
14
|
|
|
15
15
|
```vue [app/app.vue]
|
|
16
16
|
<template>
|
|
@@ -9,7 +9,7 @@ links:
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
::tip
|
|
12
|
-
The `<NuxtErrorBoundary>` uses Vue's [`onErrorCaptured`](https://vuejs.org/api/composition-api-lifecycle
|
|
12
|
+
The `<NuxtErrorBoundary>` uses Vue's [`onErrorCaptured`](https://vuejs.org/api/composition-api-lifecycle#onerrorcaptured) hook under the hood.
|
|
13
13
|
::
|
|
14
14
|
|
|
15
15
|
## Events
|
|
@@ -4,7 +4,7 @@ description: The <NuxtWelcome> component greets users in new projects made from
|
|
|
4
4
|
links:
|
|
5
5
|
- label: Source
|
|
6
6
|
icon: i-simple-icons-github
|
|
7
|
-
to: https://github.com/nuxt/
|
|
7
|
+
to: https://github.com/nuxt/nuxt/blob/main/packages/ui-templates/templates/welcome/index.html
|
|
8
8
|
size: xs
|
|
9
9
|
---
|
|
10
10
|
|
|
@@ -21,5 +21,5 @@ Preview the `<NuxtWelcome />` component.
|
|
|
21
21
|
::
|
|
22
22
|
|
|
23
23
|
::tip
|
|
24
|
-
This component is part of [nuxt/
|
|
24
|
+
This component is part of [`@nuxt/ui-templates`](https://github.com/nuxt/nuxt/tree/main/packages/ui-templates) package.
|
|
25
25
|
::
|