@nuxt/docs 3.20.1 → 3.20.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/03.configuration.md +3 -3
- package/1.getting-started/04.views.md +5 -5
- package/1.getting-started/05.assets.md +7 -7
- package/1.getting-started/06.styling.md +3 -3
- package/1.getting-started/07.routing.md +5 -5
- package/1.getting-started/08.seo-meta.md +2 -2
- package/1.getting-started/09.transitions.md +6 -6
- package/1.getting-started/11.state-management.md +2 -2
- package/1.getting-started/12.error-handling.md +3 -3
- package/1.getting-started/14.layers.md +3 -3
- package/1.getting-started/16.deployment.md +1 -1
- package/1.getting-started/17.testing.md +1 -1
- 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.assets.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.components.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.composables.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.content.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.layouts.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.middleware.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.modules.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.node_modules.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.pages.md +6 -6
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.plugins.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.server.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.shared.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.utils.md +3 -3
- package/{2.guide/1.directory-structure → 2.directory-structure}/2.env.md +1 -1
- 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.app.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/3.error.md +1 -3
- package/{2.guide/1.directory-structure → 2.directory-structure}/3.nuxt-config.md +1 -1
- package/2.directory-structure/index.md +61 -0
- package/{2.guide → 3.guide}/0.index.md +6 -9
- package/{2.guide/2.concepts → 3.guide/1.concepts}/1.auto-imports.md +4 -4
- package/{2.guide/2.concepts → 3.guide/1.concepts}/10.nuxt-lifecycle.md +3 -3
- package/{2.guide/2.concepts → 3.guide/1.concepts}/2.vuejs-development.md +3 -3
- package/{2.guide/2.concepts → 3.guide/1.concepts}/3.rendering.md +1 -1
- package/{2.guide/2.concepts → 3.guide/1.concepts}/4.server-engine.md +2 -2
- package/{2.guide/2.concepts → 3.guide/1.concepts}/5.modules.md +1 -1
- package/{2.guide/2.concepts → 3.guide/1.concepts}/8.typescript.md +2 -2
- package/{2.guide/4.recipes → 3.guide/3.recipes}/1.custom-routing.md +1 -1
- package/{2.guide/4.recipes → 3.guide/3.recipes}/2.vite-plugin.md +1 -1
- package/{2.guide/4.recipes → 3.guide/3.recipes}/3.custom-usefetch.md +1 -1
- package/{2.guide/3.going-further → 3.guide/4.going-further}/1.experimental-features.md +2 -2
- package/{2.guide/3.going-further → 3.guide/4.going-further}/1.internals.md +2 -2
- package/{2.guide/3.going-further → 3.guide/4.going-further}/10.runtime-config.md +1 -1
- package/{2.guide/3.going-further → 3.guide/4.going-further}/2.hooks.md +2 -2
- package/{2.guide/3.going-further → 3.guide/4.going-further}/3.modules.md +2 -2
- package/{2.guide/3.going-further → 3.guide/4.going-further}/6.nuxt-app.md +1 -1
- package/{2.guide/3.going-further → 3.guide/4.going-further}/7.layers.md +11 -11
- package/{3.api → 4.api}/1.components/12.nuxt-route-announcer.md +1 -1
- package/{3.api → 4.api}/1.components/2.nuxt-page.md +1 -1
- package/{3.api → 4.api}/1.components/3.nuxt-layout.md +2 -2
- package/{3.api → 4.api}/1.components/5.nuxt-loading-indicator.md +1 -1
- package/{3.api → 4.api}/2.composables/use-nuxt-app.md +4 -4
- package/{3.api → 4.api}/2.composables/use-response-header.md +1 -1
- package/{3.api → 4.api}/2.composables/use-route.md +1 -1
- package/{3.api → 4.api}/2.composables/use-router.md +1 -1
- package/{3.api → 4.api}/3.utils/$fetch.md +1 -1
- package/{3.api → 4.api}/3.utils/abort-navigation.md +1 -1
- package/{3.api → 4.api}/3.utils/add-route-middleware.md +1 -1
- package/{3.api → 4.api}/3.utils/define-nuxt-plugin.md +1 -1
- package/{3.api → 4.api}/3.utils/define-nuxt-route-middleware.md +1 -1
- package/{3.api → 4.api}/3.utils/define-page-meta.md +5 -5
- package/{3.api → 4.api}/3.utils/update-app-config.md +1 -1
- package/{3.api → 4.api}/4.commands/module.md +2 -2
- package/{3.api → 4.api}/4.commands/prepare.md +1 -1
- package/{3.api → 4.api}/4.commands/preview.md +1 -1
- package/{3.api → 4.api}/4.commands/typecheck.md +1 -1
- package/{3.api → 4.api}/6.advanced/1.hooks.md +1 -1
- package/5.community/6.roadmap.md +6 -6
- package/5.community/7.changelog.md +10 -0
- package/6.bridge/1.overview.md +1 -1
- package/6.bridge/4.plugins-and-middleware.md +2 -2
- package/7.migration/2.configuration.md +1 -1
- package/7.migration/3.auto-imports.md +1 -1
- package/7.migration/6.pages-and-layouts.md +4 -4
- package/package.json +1 -1
- /package/{2.guide/1.directory-structure → 2.directory-structure}/.navigation.yml +0 -0
- /package/{2.guide/1.directory-structure → 2.directory-structure}/1.public.md +0 -0
- /package/{2.guide/1.directory-structure → 2.directory-structure}/2.gitignore.md +0 -0
- /package/{2.guide/1.directory-structure → 2.directory-structure}/3.app-config.md +0 -0
- /package/{2.guide/1.directory-structure → 2.directory-structure}/3.package.md +0 -0
- /package/{2.guide/1.directory-structure → 2.directory-structure}/3.tsconfig.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/2.concepts → 3.guide/1.concepts}/7.esm.md +0 -0
- /package/{2.guide/2.concepts → 3.guide/1.concepts}/9.code-style.md +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}/hydration.md +0 -0
- /package/{2.guide/5.best-practices → 3.guide/2.best-practices}/performance.md +0 -0
- /package/{2.guide/5.best-practices → 3.guide/2.best-practices}/plugins.md +0 -0
- /package/{2.guide/4.recipes → 3.guide/3.recipes}/.navigation.yml +0 -0
- /package/{2.guide/4.recipes → 3.guide/3.recipes}/4.sessions-and-authentication.md +0 -0
- /package/{2.guide/3.going-further → 3.guide/4.going-further}/.navigation.yml +0 -0
- /package/{2.guide/3.going-further → 3.guide/4.going-further}/1.events.md +0 -0
- /package/{2.guide/3.going-further → 3.guide/4.going-further}/1.features.md +0 -0
- /package/{2.guide/3.going-further → 3.guide/4.going-further}/11.nightly-release-channel.md +0 -0
- /package/{2.guide/3.going-further → 3.guide/4.going-further}/4.kit.md +0 -0
- /package/{2.guide/3.going-further → 3.guide/4.going-further}/9.debugging.md +0 -0
- /package/{2.guide/3.going-further → 3.guide/4.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/10.nuxt-picture.md +0 -0
- /package/{3.api → 4.api}/1.components/11.teleports.md +0 -0
- /package/{3.api → 4.api}/1.components/13.nuxt-time.md +0 -0
- /package/{3.api → 4.api}/1.components/4.nuxt-link.md +0 -0
- /package/{3.api → 4.api}/1.components/6.nuxt-error-boundary.md +0 -0
- /package/{3.api → 4.api}/1.components/7.nuxt-welcome.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-app-config.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-async-data.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-cookie.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-error.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-fetch.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-head-safe.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-head.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-hydration.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-lazy-async-data.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-lazy-fetch.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-loading-indicator.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-nuxt-data.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-preview-mode.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-request-event.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-request-fetch.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-request-header.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-request-headers.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-request-url.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-route-announcer.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-runtime-config.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-runtime-hook.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}/2.composables/use-state.md +0 -0
- /package/{3.api → 4.api}/3.utils/.navigation.yml +0 -0
- /package/{3.api → 4.api}/3.utils/call-once.md +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-lazy-hydration-component.md +0 -0
- /package/{3.api → 4.api}/3.utils/define-nuxt-component.md +0 -0
- /package/{3.api → 4.api}/3.utils/define-route-rules.md +0 -0
- /package/{3.api → 4.api}/3.utils/navigate-to.md +0 -0
- /package/{3.api → 4.api}/3.utils/on-before-route-leave.md +0 -0
- /package/{3.api → 4.api}/3.utils/on-before-route-update.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-cookie.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}/4.commands/add.md +0 -0
- /package/{3.api → 4.api}/4.commands/analyze.md +0 -0
- /package/{3.api → 4.api}/4.commands/build-module.md +0 -0
- /package/{3.api → 4.api}/4.commands/build.md +0 -0
- /package/{3.api → 4.api}/4.commands/cleanup.md +0 -0
- /package/{3.api → 4.api}/4.commands/dev.md +0 -0
- /package/{3.api → 4.api}/4.commands/devtools.md +0 -0
- /package/{3.api → 4.api}/4.commands/generate.md +0 -0
- /package/{3.api → 4.api}/4.commands/info.md +0 -0
- /package/{3.api → 4.api}/4.commands/init.md +0 -0
- /package/{3.api → 4.api}/4.commands/test.md +0 -0
- /package/{3.api → 4.api}/4.commands/upgrade.md +0 -0
- /package/{3.api → 4.api}/5.kit/.navigation.yml +0 -0
- /package/{3.api → 4.api}/5.kit/1.modules.md +0 -0
- /package/{3.api → 4.api}/5.kit/10.runtime-config.md +0 -0
- /package/{3.api → 4.api}/5.kit/10.templates.md +0 -0
- /package/{3.api → 4.api}/5.kit/11.nitro.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/14.builder.md +0 -0
- /package/{3.api → 4.api}/5.kit/15.examples.md +0 -0
- /package/{3.api → 4.api}/5.kit/16.layers.md +0 -0
- /package/{3.api → 4.api}/5.kit/2.programmatic.md +0 -0
- /package/{3.api → 4.api}/5.kit/3.compatibility.md +0 -0
- /package/{3.api → 4.api}/5.kit/4.autoimports.md +0 -0
- /package/{3.api → 4.api}/5.kit/5.components.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}/6.nuxt-config.md +0 -0
- /package/{3.api → 4.api}/index.md +0 -0
|
@@ -19,7 +19,7 @@ If you want to play around with Nuxt in your browser, you can [try it out in one
|
|
|
19
19
|
|
|
20
20
|
Nuxt uses conventions and an opinionated directory structure to automate repetitive tasks and allow developers to focus on pushing features. The configuration file can still customize and override its default behaviors.
|
|
21
21
|
|
|
22
|
-
- **File-based routing:** define routes based on the structure of your [`pages/` directory](/docs/3.x/
|
|
22
|
+
- **File-based routing:** define routes based on the structure of your [`pages/` directory](/docs/3.x/directory-structure/pages). This can make it easier to organize your application and avoid the need for manual route configuration.
|
|
23
23
|
- **Code splitting:** Nuxt automatically splits your code into smaller chunks, which can help reduce the initial load time of your application.
|
|
24
24
|
- **Server-side rendering out of the box:** Nuxt comes with built-in SSR capabilities, so you don't have to set up a separate server yourself.
|
|
25
25
|
- **Auto-imports:** write Vue composables and components in their respective directories and use them without having to import them with the benefits of tree-shaking and optimized JS bundles.
|
|
@@ -4,11 +4,11 @@ description: Nuxt is configured with sensible defaults to make you productive.
|
|
|
4
4
|
navigation.icon: i-lucide-cog
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
By default, Nuxt is configured to cover most use cases. The [`nuxt.config.ts`](/docs/3.x/
|
|
7
|
+
By default, Nuxt is configured to cover most use cases. The [`nuxt.config.ts`](/docs/3.x/directory-structure/nuxt-config) file can override or extend this default configuration.
|
|
8
8
|
|
|
9
9
|
## Nuxt Configuration
|
|
10
10
|
|
|
11
|
-
The [`nuxt.config.ts`](/docs/3.x/
|
|
11
|
+
The [`nuxt.config.ts`](/docs/3.x/directory-structure/nuxt-config) file is located at the root of a Nuxt project and can override or extend the application's behavior.
|
|
12
12
|
|
|
13
13
|
A minimal configuration file exports the `defineNuxtConfig` function containing an object with your configuration. The `defineNuxtConfig` helper is globally available without import.
|
|
14
14
|
|
|
@@ -145,7 +145,7 @@ Non primitive JS types | ❌ No | ✅ Yes
|
|
|
145
145
|
|
|
146
146
|
## External Configuration Files
|
|
147
147
|
|
|
148
|
-
Nuxt uses [`nuxt.config.ts`](/docs/3.x/
|
|
148
|
+
Nuxt uses [`nuxt.config.ts`](/docs/3.x/directory-structure/nuxt-config) file as the single source of truth for configurations and skips reading external configuration files. During the course of building your project, you may have a need to configure those. The following table highlights common configurations and, where applicable, how they can be configured with Nuxt.
|
|
149
149
|
|
|
150
150
|
Name | Config File | How To Configure
|
|
151
151
|
---------------------------------------------|---------------------------|-------------------------
|
|
@@ -26,7 +26,7 @@ If you are familiar with Vue, you might wonder where `main.js` is (the file that
|
|
|
26
26
|
|
|
27
27
|

|
|
28
28
|
|
|
29
|
-
Most components are reusable pieces of the user interface, like buttons and menus. In Nuxt, you can create these components in the [`components/`](/docs/3.x/
|
|
29
|
+
Most components are reusable pieces of the user interface, like buttons and menus. In Nuxt, you can create these components in the [`components/`](/docs/3.x/directory-structure/components) directory, and they will be automatically available across your application without having to explicitly import them.
|
|
30
30
|
|
|
31
31
|
::code-group
|
|
32
32
|
|
|
@@ -55,9 +55,9 @@ Most components are reusable pieces of the user interface, like buttons and menu
|
|
|
55
55
|
|
|
56
56
|

|
|
57
57
|
|
|
58
|
-
Pages represent views for each specific route pattern. Every file in the [`pages/`](/docs/3.x/
|
|
58
|
+
Pages represent views for each specific route pattern. Every file in the [`pages/`](/docs/3.x/directory-structure/pages) directory represents a different route displaying its content.
|
|
59
59
|
|
|
60
|
-
To use pages, create `pages/index.vue` file and add `<NuxtPage />` component to the [`app.vue`](/docs/3.x/
|
|
60
|
+
To use pages, create `pages/index.vue` file and add `<NuxtPage />` component to the [`app.vue`](/docs/3.x/directory-structure/app) (or remove `app.vue` for default entry). You can now create more pages and their corresponding routes by adding new files in the [`pages/`](/docs/3.x/directory-structure/pages) directory.
|
|
61
61
|
|
|
62
62
|
::code-group
|
|
63
63
|
|
|
@@ -91,7 +91,7 @@ To use pages, create `pages/index.vue` file and add `<NuxtPage />` component to
|
|
|
91
91
|
Layouts are wrappers around pages that contain a common User Interface for several pages, such as header and footer displays. Layouts are Vue files using `<slot />` components to display the **page** content. The `layouts/default.vue` file will be used by default. Custom layouts can be set as part of your page metadata.
|
|
92
92
|
|
|
93
93
|
::note
|
|
94
|
-
If you only have a single layout in your application, we recommend using [`app.vue`](/docs/3.x/
|
|
94
|
+
If you only have a single layout in your application, we recommend using [`app.vue`](/docs/3.x/directory-structure/app) with [`<NuxtPage />`](/docs/3.x/api/components/nuxt-page) instead.
|
|
95
95
|
::
|
|
96
96
|
|
|
97
97
|
::code-group
|
|
@@ -137,7 +137,7 @@ If you only have a single layout in your application, we recommend using [`app.v
|
|
|
137
137
|
|
|
138
138
|
::
|
|
139
139
|
|
|
140
|
-
If you want to create more layouts and learn how to use them in your pages, find more information in the [Layouts section](/docs/3.x/
|
|
140
|
+
If you want to create more layouts and learn how to use them in your pages, find more information in the [Layouts section](/docs/3.x/directory-structure/layouts).
|
|
141
141
|
|
|
142
142
|
## Advanced: Extending the HTML Template
|
|
143
143
|
|
|
@@ -6,14 +6,14 @@ navigation.icon: i-lucide-image
|
|
|
6
6
|
|
|
7
7
|
Nuxt uses two directories to handle assets like stylesheets, fonts or images.
|
|
8
8
|
|
|
9
|
-
- The [`public/`](/docs/3.x/
|
|
10
|
-
- The [`assets/`](/docs/3.x/
|
|
9
|
+
- The [`public/`](/docs/3.x/directory-structure/public) directory content is served at the server root as-is.
|
|
10
|
+
- The [`assets/`](/docs/3.x/directory-structure/assets) directory contains by convention every asset that you want the build tool (Vite or webpack) to process.
|
|
11
11
|
|
|
12
12
|
## Public Directory
|
|
13
13
|
|
|
14
|
-
The [`public/`](/docs/3.x/
|
|
14
|
+
The [`public/`](/docs/3.x/directory-structure/public) directory is used as a public server for static assets publicly available at a defined URL of your application.
|
|
15
15
|
|
|
16
|
-
You can get a file in the [`public/`](/docs/3.x/
|
|
16
|
+
You can get a file in the [`public/`](/docs/3.x/directory-structure/public) directory from your application's code or from a browser by the root URL `/`.
|
|
17
17
|
|
|
18
18
|
### Example
|
|
19
19
|
|
|
@@ -32,9 +32,9 @@ For example, referencing an image file in the `public/img/` directory, available
|
|
|
32
32
|
|
|
33
33
|
Nuxt uses [Vite](https://vite.dev/guide/assets.html) (default) or [webpack](https://webpack.js.org/guides/asset-management) to build and bundle your application. The main function of these build tools is to process JavaScript files, but they can be extended through [plugins](https://vite.dev/plugins) (for Vite) or [loaders](https://webpack.js.org/loaders) (for webpack) to process other kinds of assets, like stylesheets, fonts or SVGs. This step transforms the original file, mainly for performance or caching purposes (such as stylesheet minification or browser cache invalidation).
|
|
34
34
|
|
|
35
|
-
By convention, Nuxt uses the [`assets/`](/docs/3.x/
|
|
35
|
+
By convention, Nuxt uses the [`assets/`](/docs/3.x/directory-structure/assets) directory to store these files but there is no auto-scan functionality for this directory, and you can use any other name for it.
|
|
36
36
|
|
|
37
|
-
In your application's code, you can reference a file located in the [`assets/`](/docs/3.x/
|
|
37
|
+
In your application's code, you can reference a file located in the [`assets/`](/docs/3.x/directory-structure/assets) directory by using the `~/assets/` path.
|
|
38
38
|
|
|
39
39
|
### Example
|
|
40
40
|
|
|
@@ -50,5 +50,5 @@ For example, referencing an image file that will be processed if a build tool is
|
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
::note
|
|
53
|
-
Nuxt won't serve files in the [`assets/`](/docs/3.x/
|
|
53
|
+
Nuxt won't serve files in the [`assets/`](/docs/3.x/directory-structure/assets) directory at a static URL like `/assets/my-file.png`. If you need a static URL, use the [`public/`](#public-directory) directory.
|
|
54
54
|
::
|
|
@@ -9,7 +9,7 @@ You can use CSS preprocessors, CSS frameworks, UI libraries and Nuxt modules to
|
|
|
9
9
|
|
|
10
10
|
## Local Stylesheets
|
|
11
11
|
|
|
12
|
-
If you're writing local stylesheets, the natural place to put them is the [`assets/` directory](/docs/3.x/
|
|
12
|
+
If you're writing local stylesheets, the natural place to put them is the [`assets/` directory](/docs/3.x/directory-structure/assets).
|
|
13
13
|
|
|
14
14
|
### Importing Within Components
|
|
15
15
|
|
|
@@ -37,7 +37,7 @@ The stylesheets will be inlined in the HTML rendered by Nuxt.
|
|
|
37
37
|
### The CSS Property
|
|
38
38
|
|
|
39
39
|
You can also use the `css` property in the Nuxt configuration.
|
|
40
|
-
The natural place for your stylesheets is the [`assets/` directory](/docs/3.x/
|
|
40
|
+
The natural place for your stylesheets is the [`assets/` directory](/docs/3.x/directory-structure/assets). You can then reference its path and Nuxt will include it to all the pages of your application.
|
|
41
41
|
|
|
42
42
|
```ts [nuxt.config.ts]
|
|
43
43
|
export default defineNuxtConfig({
|
|
@@ -515,7 +515,7 @@ Here are a few modules to help you get started:
|
|
|
515
515
|
- [Nuxt UI](https://ui.nuxt.com): A UI Library for Modern Web Apps
|
|
516
516
|
- [Panda CSS](https://panda-css.com/docs/installation/nuxt): CSS-in-JS engine that generates atomic CSS at build time
|
|
517
517
|
|
|
518
|
-
Nuxt modules provide you with a good developer experience out of the box, but remember that if your favorite tool doesn't have a module, it doesn't mean that you can't use it with Nuxt! You can configure it yourself for your own project. Depending on the tool, you might need to use a [Nuxt plugin](/docs/3.x/
|
|
518
|
+
Nuxt modules provide you with a good developer experience out of the box, but remember that if your favorite tool doesn't have a module, it doesn't mean that you can't use it with Nuxt! You can configure it yourself for your own project. Depending on the tool, you might need to use a [Nuxt plugin](/docs/3.x/directory-structure/plugins) and/or [make your own module](/docs/3.x/guide/going-further/modules). Share them with the [community](/modules) if you do!
|
|
519
519
|
|
|
520
520
|
### Easily Load Webfonts
|
|
521
521
|
|
|
@@ -4,11 +4,11 @@ description: Nuxt file-system routing creates a route for every file in the page
|
|
|
4
4
|
navigation.icon: i-lucide-milestone
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
One core feature of Nuxt is the file system router. Every Vue file inside the [`pages/`](/docs/3.x/
|
|
7
|
+
One core feature of Nuxt is the file system router. Every Vue file inside the [`pages/`](/docs/3.x/directory-structure/pages) directory creates a corresponding URL (or route) that displays the contents of the file. By using dynamic imports for each page, Nuxt leverages code-splitting to ship the minimum amount of JavaScript for the requested route.
|
|
8
8
|
|
|
9
9
|
## Pages
|
|
10
10
|
|
|
11
|
-
Nuxt routing is based on [vue-router](https://router.vuejs.org) and generates the routes from every component created in the [`pages/` directory](/docs/3.x/
|
|
11
|
+
Nuxt routing is based on [vue-router](https://router.vuejs.org) and generates the routes from every component created in the [`pages/` directory](/docs/3.x/directory-structure/pages), based on their filename.
|
|
12
12
|
|
|
13
13
|
This file system routing uses naming conventions to create dynamic and nested routes:
|
|
14
14
|
|
|
@@ -91,14 +91,14 @@ Route middleware runs within the Vue part of your Nuxt app. Despite the similar
|
|
|
91
91
|
::
|
|
92
92
|
|
|
93
93
|
::important
|
|
94
|
-
Route middleware does **not** run for server routes (e.g. `/api/*`) or other server requests. To apply middleware to these requests, use [server middleware](/docs/3.x/
|
|
94
|
+
Route middleware does **not** run for server routes (e.g. `/api/*`) or other server requests. To apply middleware to these requests, use [server middleware](/docs/3.x/directory-structure/server#server-middleware) instead.
|
|
95
95
|
::
|
|
96
96
|
|
|
97
97
|
There are three kinds of route middleware:
|
|
98
98
|
|
|
99
99
|
1. Anonymous (or inline) route middleware, which are defined directly in the pages where they are used.
|
|
100
|
-
2. Named route middleware, which are placed in the [`middleware/`](/docs/3.x/
|
|
101
|
-
3. Global route middleware, which are placed in the [`middleware/`](/docs/3.x/
|
|
100
|
+
2. Named route middleware, which are placed in the [`middleware/`](/docs/3.x/directory-structure/middleware) directory and will be automatically loaded via asynchronous import when used on a page. (**Note**: The route middleware name is normalized to kebab-case, so `someMiddleware` becomes `some-middleware`.)
|
|
101
|
+
3. Global route middleware, which are placed in the [`middleware/`](/docs/3.x/directory-structure/middleware) directory (with a `.global` suffix) and will be automatically run on every route change.
|
|
102
102
|
|
|
103
103
|
Example of an `auth` middleware protecting the `/dashboard` page:
|
|
104
104
|
|
|
@@ -9,7 +9,7 @@ and numerous configuration options to manage your app's head and SEO meta tags.
|
|
|
9
9
|
|
|
10
10
|
## Nuxt Config
|
|
11
11
|
|
|
12
|
-
Providing an [`app.head`](/docs/3.x/api/nuxt-config#head) property in your [`nuxt.config.ts`](/docs/3.x/
|
|
12
|
+
Providing an [`app.head`](/docs/3.x/api/nuxt-config#head) property in your [`nuxt.config.ts`](/docs/3.x/directory-structure/nuxt-config) allows you to statically customize the head for your entire app.
|
|
13
13
|
|
|
14
14
|
::important
|
|
15
15
|
This method does not allow you to provide reactive data. We recommend using `useHead()` in `app.vue`.
|
|
@@ -273,7 +273,7 @@ useHead({
|
|
|
273
273
|
|
|
274
274
|
### With `definePageMeta`
|
|
275
275
|
|
|
276
|
-
Within your [`pages/` directory](/docs/3.x/
|
|
276
|
+
Within your [`pages/` directory](/docs/3.x/directory-structure/pages), you can use `definePageMeta` along with [`useHead`](/docs/3.x/api/composables/use-head) to set metadata based on the current route.
|
|
277
277
|
|
|
278
278
|
For example, you can first set the current page title (this is extracted at build time via a macro, so it can't be set dynamically):
|
|
279
279
|
|
|
@@ -10,7 +10,7 @@ Nuxt leverages Vue's [`<Transition>`](https://vuejs.org/guide/built-ins/transiti
|
|
|
10
10
|
|
|
11
11
|
## Page Transitions
|
|
12
12
|
|
|
13
|
-
You can enable page transitions to apply an automatic transition for all your [pages](/docs/3.x/
|
|
13
|
+
You can enable page transitions to apply an automatic transition for all your [pages](/docs/3.x/directory-structure/pages).
|
|
14
14
|
|
|
15
15
|
```ts twoslash [nuxt.config.ts]
|
|
16
16
|
export default defineNuxtConfig({
|
|
@@ -24,7 +24,7 @@ export default defineNuxtConfig({
|
|
|
24
24
|
If you are changing layouts as well as page, the page transition you set here will not run. Instead, you should set a [layout transition](/docs/3.x/getting-started/transitions#layout-transitions).
|
|
25
25
|
::
|
|
26
26
|
|
|
27
|
-
To start adding transition between your pages, add the following CSS to your [`app.vue`](/docs/3.x/
|
|
27
|
+
To start adding transition between your pages, add the following CSS to your [`app.vue`](/docs/3.x/directory-structure/app):
|
|
28
28
|
|
|
29
29
|
::code-group
|
|
30
30
|
|
|
@@ -115,7 +115,7 @@ Moving to the about page will add the 3d rotation effect:
|
|
|
115
115
|
|
|
116
116
|
## Layout Transitions
|
|
117
117
|
|
|
118
|
-
You can enable layout transitions to apply an automatic transition for all your [layouts](/docs/3.x/
|
|
118
|
+
You can enable layout transitions to apply an automatic transition for all your [layouts](/docs/3.x/directory-structure/layouts).
|
|
119
119
|
|
|
120
120
|
```ts twoslash [nuxt.config.ts]
|
|
121
121
|
export default defineNuxtConfig({
|
|
@@ -125,7 +125,7 @@ export default defineNuxtConfig({
|
|
|
125
125
|
})
|
|
126
126
|
```
|
|
127
127
|
|
|
128
|
-
To start adding transition between your pages and layouts, add the following CSS to your [`app.vue`](/docs/3.x/
|
|
128
|
+
To start adding transition between your pages and layouts, add the following CSS to your [`app.vue`](/docs/3.x/directory-structure/app):
|
|
129
129
|
|
|
130
130
|
::code-group
|
|
131
131
|
|
|
@@ -315,7 +315,7 @@ Learn more about additional [JavaScript hooks](https://vuejs.org/guide/built-ins
|
|
|
315
315
|
|
|
316
316
|
## Dynamic Transitions
|
|
317
317
|
|
|
318
|
-
To apply dynamic transitions using conditional logic, you can leverage inline [middleware](/docs/3.x/
|
|
318
|
+
To apply dynamic transitions using conditional logic, you can leverage inline [middleware](/docs/3.x/directory-structure/middleware) to assign a different transition name to `to.meta.pageTransition`.
|
|
319
319
|
|
|
320
320
|
::code-group
|
|
321
321
|
|
|
@@ -434,7 +434,7 @@ The possible values are: `false`, `true`, or `'always'`.
|
|
|
434
434
|
|
|
435
435
|
If set to true, Nuxt will not apply transitions if the user's browser matches `prefers-reduced-motion: reduce` (recommended). If set to `always`, Nuxt will always apply the transition and it is up to you to respect the user's preference.
|
|
436
436
|
|
|
437
|
-
By default, view transitions are enabled for all [pages](/docs/3.x/
|
|
437
|
+
By default, view transitions are enabled for all [pages](/docs/3.x/directory-structure/pages), but you can set a different global default.
|
|
438
438
|
|
|
439
439
|
```ts twoslash [nuxt.config.ts]
|
|
440
440
|
export default defineNuxtConfig({
|
|
@@ -61,7 +61,7 @@ To globally invalidate cached state, see [`clearNuxtState`](/docs/3.x/api/utils/
|
|
|
61
61
|
|
|
62
62
|
### Initializing State
|
|
63
63
|
|
|
64
|
-
Most of the time, you will want to initialize your state with data that resolves asynchronously. You can use the [`app.vue`](/docs/3.x/
|
|
64
|
+
Most of the time, you will want to initialize your state with data that resolves asynchronously. You can use the [`app.vue`](/docs/3.x/directory-structure/app) component with the [`callOnce`](/docs/3.x/api/utils/call-once) util to do so.
|
|
65
65
|
|
|
66
66
|
```vue twoslash [app.vue]
|
|
67
67
|
<script setup lang="ts">
|
|
@@ -198,7 +198,7 @@ const date = useLocaleDate(new Date('2016-10-26'))
|
|
|
198
198
|
|
|
199
199
|
## Shared State
|
|
200
200
|
|
|
201
|
-
By using [auto-imported composables](/docs/3.x/
|
|
201
|
+
By using [auto-imported composables](/docs/3.x/directory-structure/composables) we can define global type-safe states and import them across the app.
|
|
202
202
|
|
|
203
203
|
```ts twoslash [composables/states.ts]
|
|
204
204
|
export const useColor = () => useState<string>('color', () => 'pink')
|
|
@@ -8,7 +8,7 @@ Nuxt is a full-stack framework, which means there are several sources of unpreve
|
|
|
8
8
|
|
|
9
9
|
- Errors during the Vue rendering lifecycle (SSR & CSR)
|
|
10
10
|
- Server and client startup errors (SSR + CSR)
|
|
11
|
-
- Errors during Nitro server lifecycle ([`server/`](/docs/3.x/
|
|
11
|
+
- Errors during Nitro server lifecycle ([`server/`](/docs/3.x/directory-structure/server) directory)
|
|
12
12
|
- Errors downloading JS chunks
|
|
13
13
|
|
|
14
14
|
::tip
|
|
@@ -45,7 +45,7 @@ Note that the `vue:error` hook is based on [`onErrorCaptured`](https://vuejs.org
|
|
|
45
45
|
Nuxt will call the `app:error` hook if there are any errors in starting your Nuxt application.
|
|
46
46
|
|
|
47
47
|
This includes:
|
|
48
|
-
- running [Nuxt plugins](/docs/3.x/
|
|
48
|
+
- running [Nuxt plugins](/docs/3.x/directory-structure/plugins)
|
|
49
49
|
- processing `app:created` and `app:beforeMount` hooks
|
|
50
50
|
- rendering your Vue app to HTML (during SSR)
|
|
51
51
|
- mounting the app (on client-side), though you should handle this case with `onErrorCaptured` or with `vue:error`
|
|
@@ -107,7 +107,7 @@ const handleError = () => clearError({ redirect: '/' })
|
|
|
107
107
|
</template>
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
-
::read-more{to="/docs/
|
|
110
|
+
::read-more{to="/docs/3.x/directory-structure/error"}
|
|
111
111
|
Read more about `error.vue` and its uses.
|
|
112
112
|
::
|
|
113
113
|
|
|
@@ -9,8 +9,8 @@ One of the core features of Nuxt is the layers and extending support. You can ex
|
|
|
9
9
|
## Use Cases
|
|
10
10
|
|
|
11
11
|
- Share reusable configuration presets across projects using `nuxt.config` and `app.config`
|
|
12
|
-
- Create a component library using [`components/`](/docs/3.x/
|
|
13
|
-
- Create utility and composable library using [`composables/`](/docs/3.x/
|
|
12
|
+
- Create a component library using [`components/`](/docs/3.x/directory-structure/components) directory
|
|
13
|
+
- Create utility and composable library using [`composables/`](/docs/3.x/directory-structure/composables) and [`utils/`](/docs/3.x/directory-structure/utils) directories
|
|
14
14
|
- Create Nuxt module presets
|
|
15
15
|
- Share standard setup across projects
|
|
16
16
|
- Create Nuxt themes
|
|
@@ -30,7 +30,7 @@ In addition, named layer aliases to the `srcDir` of each of these layers will au
|
|
|
30
30
|
Named layer aliases were introduced in Nuxt v3.16.0.
|
|
31
31
|
::
|
|
32
32
|
|
|
33
|
-
In addition, you can extend from a layer by adding the [extends](/docs/3.x/api/nuxt-config#extends) property to your [`nuxt.config`](/docs/3.x/
|
|
33
|
+
In addition, you can extend from a layer by adding the [extends](/docs/3.x/api/nuxt-config#extends) property to your [`nuxt.config`](/docs/3.x/directory-structure/nuxt-config) file.
|
|
34
34
|
|
|
35
35
|
```ts [nuxt.config.ts]
|
|
36
36
|
export default defineNuxtConfig({
|
|
@@ -95,7 +95,7 @@ Nuxt can be deployed to several cloud providers with a minimal amount of configu
|
|
|
95
95
|
|
|
96
96
|
In addition to Node.js servers and static hosting services, a Nuxt project can be deployed with several well-tested presets and minimal amount of configuration.
|
|
97
97
|
|
|
98
|
-
You can explicitly set the desired preset in the [`nuxt.config.ts`](/docs/3.x/
|
|
98
|
+
You can explicitly set the desired preset in the [`nuxt.config.ts`](/docs/3.x/directory-structure/nuxt-config) file:
|
|
99
99
|
|
|
100
100
|
```ts twoslash [nuxt.config.ts]
|
|
101
101
|
export default defineNuxtConfig({
|
|
@@ -267,7 +267,7 @@ it('can also mount an app', async () => {
|
|
|
267
267
|
|
|
268
268
|
This should be used together with utilities from Testing Library, e.g. `screen` and `fireEvent`. Install [@testing-library/vue](https://testing-library.com/docs/vue-testing-library/intro) in your project to use these.
|
|
269
269
|
|
|
270
|
-
Additionally, Testing Library also relies on testing globals for cleanup. You should turn these on in your [Vitest config](https://vitest.dev/config
|
|
270
|
+
Additionally, Testing Library also relies on testing globals for cleanup. You should turn these on in your [Vitest config](https://vitest.dev/config/globals).
|
|
271
271
|
|
|
272
272
|
The passed in component will be rendered inside a `<div id="test-wrapper"></div>`.
|
|
273
273
|
|
|
@@ -6,7 +6,7 @@ navigation.icon: i-vscode-icons-folder-type-temp
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
::important
|
|
9
|
-
This directory should be added to your [`.gitignore`](/docs/3.x/
|
|
9
|
+
This directory should be added to your [`.gitignore`](/docs/3.x/directory-structure/gitignore) file to avoid pushing the dev build output to your repository.
|
|
10
10
|
::
|
|
11
11
|
|
|
12
12
|
This directory is interesting if you want to learn more about the files Nuxt generates based on your directory structure.
|
|
@@ -6,7 +6,7 @@ navigation.icon: i-vscode-icons-folder-type-package
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
::important
|
|
9
|
-
This directory should be added to your [`.gitignore`](/docs/3.x/
|
|
9
|
+
This directory should be added to your [`.gitignore`](/docs/3.x/directory-structure/gitignore) file to avoid pushing the build output to your repository.
|
|
10
10
|
::
|
|
11
11
|
|
|
12
12
|
Use this directory to deploy your Nuxt application to production.
|
|
@@ -9,8 +9,8 @@ The directory usually contains the following types of files:
|
|
|
9
9
|
|
|
10
10
|
- Stylesheets (CSS, SASS, etc.)
|
|
11
11
|
- Fonts
|
|
12
|
-
- Images that won't be served from the [`public/`](/docs/3.x/
|
|
12
|
+
- Images that won't be served from the [`public/`](/docs/3.x/directory-structure/public) directory.
|
|
13
13
|
|
|
14
|
-
If you want to serve assets from the server, we recommend taking a look at the [`public/`](/docs/3.x/
|
|
14
|
+
If you want to serve assets from the server, we recommend taking a look at the [`public/`](/docs/3.x/directory-structure/public) directory.
|
|
15
15
|
|
|
16
16
|
:read-more{to="/docs/getting-started/assets"}
|
|
@@ -358,7 +358,7 @@ Any nested directories need to be added first as they are scanned in order.
|
|
|
358
358
|
|
|
359
359
|
## npm Packages
|
|
360
360
|
|
|
361
|
-
If you want to auto-import components from an npm package, you can use [`addComponent`](/docs/3.x/api/kit/components#addcomponent) in a [local module](/docs/3.x/
|
|
361
|
+
If you want to auto-import components from an npm package, you can use [`addComponent`](/docs/3.x/api/kit/components#addcomponent) in a [local module](/docs/3.x/directory-structure/modules) to register them.
|
|
362
362
|
|
|
363
363
|
::code-group
|
|
364
364
|
|
|
@@ -71,7 +71,7 @@ export const useFoo = () => {
|
|
|
71
71
|
|
|
72
72
|
### Access plugin injections
|
|
73
73
|
|
|
74
|
-
You can access [plugin injections](/docs/3.x/
|
|
74
|
+
You can access [plugin injections](/docs/3.x/directory-structure/plugins#providing-helpers) from composables:
|
|
75
75
|
|
|
76
76
|
```ts [composables/test.ts]
|
|
77
77
|
export const useHello = () => {
|
|
@@ -82,7 +82,7 @@ export const useHello = () => {
|
|
|
82
82
|
|
|
83
83
|
## How Files Are Scanned
|
|
84
84
|
|
|
85
|
-
Nuxt only scans files at the top level of the [`composables/` directory](/docs/3.x/
|
|
85
|
+
Nuxt only scans files at the top level of the [`composables/` directory](/docs/3.x/directory-structure/composables), e.g.:
|
|
86
86
|
|
|
87
87
|
```bash [Directory Structure]
|
|
88
88
|
-| composables/
|
|
@@ -5,7 +5,7 @@ description: Use the content/ directory to create a file-based CMS for your appl
|
|
|
5
5
|
navigation.icon: i-vscode-icons-folder-type-log
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
[Nuxt Content](https://content.nuxt.com) reads the [`content/` directory](/docs/3.x/
|
|
8
|
+
[Nuxt Content](https://content.nuxt.com) reads the [`content/` directory](/docs/3.x/directory-structure/content) in your project and parses `.md`, `.yml`, `.csv` and `.json` files to create a file-based CMS for your application.
|
|
9
9
|
|
|
10
10
|
- Render your content with built-in components.
|
|
11
11
|
- Query your content with a MongoDB-like API.
|
|
@@ -36,7 +36,7 @@ The module automatically loads and parses them.
|
|
|
36
36
|
|
|
37
37
|
## Render Content
|
|
38
38
|
|
|
39
|
-
To render content pages, add a [catch-all route](/docs/3.x/
|
|
39
|
+
To render content pages, add a [catch-all route](/docs/3.x/directory-structure/pages/#catch-all-route) using the [`<ContentRenderer>`](https://content.nuxt.com/docs/components/content-renderer) component:
|
|
40
40
|
|
|
41
41
|
```vue [pages/[...slug\\].vue]
|
|
42
42
|
<script lang="ts" setup>
|
|
@@ -11,7 +11,7 @@ For best performance, components placed in this directory will be automatically
|
|
|
11
11
|
|
|
12
12
|
## Enable Layouts
|
|
13
13
|
|
|
14
|
-
Layouts are enabled by adding [`<NuxtLayout>`](/docs/3.x/api/components/nuxt-layout) to your [`app.vue`](/docs/3.x/
|
|
14
|
+
Layouts are enabled by adding [`<NuxtLayout>`](/docs/3.x/api/components/nuxt-layout) to your [`app.vue`](/docs/3.x/directory-structure/app):
|
|
15
15
|
|
|
16
16
|
```vue [app.vue]
|
|
17
17
|
<template>
|
|
@@ -34,7 +34,7 @@ If no layout is specified, `layouts/default.vue` will be used.
|
|
|
34
34
|
::
|
|
35
35
|
|
|
36
36
|
::important
|
|
37
|
-
If you only have a single layout in your application, we recommend using [`app.vue`](/docs/3.x/
|
|
37
|
+
If you only have a single layout in your application, we recommend using [`app.vue`](/docs/3.x/directory-structure/app) instead.
|
|
38
38
|
::
|
|
39
39
|
|
|
40
40
|
::important
|
|
@@ -20,7 +20,7 @@ Name of middleware are normalized to kebab-case: `myMiddleware` becomes `my-midd
|
|
|
20
20
|
::
|
|
21
21
|
|
|
22
22
|
::note
|
|
23
|
-
Route middleware run within the Vue part of your Nuxt app. Despite the similar name, they are completely different from [server middleware](/docs/3.x/
|
|
23
|
+
Route middleware run within the Vue part of your Nuxt app. Despite the similar name, they are completely different from [server middleware](/docs/3.x/directory-structure/server#server-middleware), which are run in the Nitro server part of your app.
|
|
24
24
|
::
|
|
25
25
|
|
|
26
26
|
:video-accordion{title="Watch a video from Vue School on all 3 kinds of middleware" videoId="761471577" platform="vimeo"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
title: 'modules'
|
|
3
3
|
head.title: 'modules/'
|
|
4
4
|
description: Use the modules/ directory to automatically register local modules within your application.
|
|
5
|
-
navigation.icon: i-
|
|
5
|
+
navigation.icon: i-vscode-icons-folder-type-nuxt
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
It is a good place to place any local modules you develop while building your application.
|
|
@@ -11,7 +11,7 @@ The auto-registered files patterns are:
|
|
|
11
11
|
- `modules/*/index.ts`
|
|
12
12
|
- `modules/*.ts`
|
|
13
13
|
|
|
14
|
-
You don't need to add those local modules to your [`nuxt.config.ts`](/docs/3.x/
|
|
14
|
+
You don't need to add those local modules to your [`nuxt.config.ts`](/docs/3.x/directory-structure/nuxt-config) separately.
|
|
15
15
|
|
|
16
16
|
::code-group
|
|
17
17
|
|
|
@@ -8,5 +8,5 @@ navigation.icon: i-vscode-icons-folder-type-node
|
|
|
8
8
|
The package manager ([`npm`](https://docs.npmjs.com/cli/commands/npm/) or [`yarn`](https://yarnpkg.com) or [`pnpm`](https://pnpm.io/cli/install) or [`bun`](https://bun.com/package-manager)) creates this directory to store the dependencies of your project.
|
|
9
9
|
|
|
10
10
|
::important
|
|
11
|
-
This directory should be added to your [`.gitignore`](/docs/3.x/
|
|
11
|
+
This directory should be added to your [`.gitignore`](/docs/3.x/directory-structure/gitignore) file to avoid pushing the dependencies to your repository.
|
|
12
12
|
::
|
|
@@ -6,7 +6,7 @@ navigation.icon: i-vscode-icons-folder-type-view
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
::note
|
|
9
|
-
To reduce your application's bundle size, this directory is **optional**, meaning that [`vue-router`](https://router.vuejs.org) won't be included if you only use [`app.vue`](/docs/3.x/
|
|
9
|
+
To reduce your application's bundle size, this directory is **optional**, meaning that [`vue-router`](https://router.vuejs.org) won't be included if you only use [`app.vue`](/docs/3.x/directory-structure/app). To force the pages system, set `pages: true` in `nuxt.config` or have a [`app/router.options.ts`](/docs/3.x/guide/recipes/custom-routing#using-approuteroptions).
|
|
10
10
|
::
|
|
11
11
|
|
|
12
12
|
## Usage
|
|
@@ -46,7 +46,7 @@ export default defineComponent({
|
|
|
46
46
|
|
|
47
47
|
The `pages/index.vue` file will be mapped to the `/` route of your application.
|
|
48
48
|
|
|
49
|
-
If you are using [`app.vue`](/docs/3.x/
|
|
49
|
+
If you are using [`app.vue`](/docs/3.x/directory-structure/app), make sure to use the [`<NuxtPage/>`](/docs/3.x/api/components/nuxt-page) component to display the current page:
|
|
50
50
|
|
|
51
51
|
```vue [app.vue]
|
|
52
52
|
<template>
|
|
@@ -317,7 +317,7 @@ You can set a default value for this property [in your `nuxt.config`](/docs/3.x/
|
|
|
317
317
|
|
|
318
318
|
#### `layout`
|
|
319
319
|
|
|
320
|
-
You can define the layout used to render the route. This can be either false (to disable any layout), a string or a ref/computed, if you want to make it reactive in some way. [More about layouts](/docs/3.x/
|
|
320
|
+
You can define the layout used to render the route. This can be either false (to disable any layout), a string or a ref/computed, if you want to make it reactive in some way. [More about layouts](/docs/3.x/directory-structure/layouts).
|
|
321
321
|
|
|
322
322
|
#### `layoutTransition` and `pageTransition`
|
|
323
323
|
|
|
@@ -327,7 +327,7 @@ You can set default values for these properties [in your `nuxt.config`](/docs/3.
|
|
|
327
327
|
|
|
328
328
|
#### `middleware`
|
|
329
329
|
|
|
330
|
-
You can define middleware to apply before loading this page. It will be merged with all the other middleware used in any matching parent/child routes. It can be a string, a function (an anonymous/inlined middleware function following [the global before guard pattern](https://router.vuejs.org/guide/advanced/navigation-guards.html#global-before-guards)), or an array of strings/functions. [More about named middleware](/docs/3.x/
|
|
330
|
+
You can define middleware to apply before loading this page. It will be merged with all the other middleware used in any matching parent/child routes. It can be a string, a function (an anonymous/inlined middleware function following [the global before guard pattern](https://router.vuejs.org/guide/advanced/navigation-guards.html#global-before-guards)), or an array of strings/functions. [More about named middleware](/docs/3.x/directory-structure/middleware).
|
|
331
331
|
|
|
332
332
|
#### `name`
|
|
333
333
|
|
|
@@ -401,11 +401,11 @@ function navigate () {
|
|
|
401
401
|
|
|
402
402
|
## Client-Only Pages
|
|
403
403
|
|
|
404
|
-
You can define a page as [client only](/docs/3.x/
|
|
404
|
+
You can define a page as [client only](/docs/3.x/directory-structure/components#client-components) by giving it a `.client.vue` suffix. None of the content of this page will be rendered on the server.
|
|
405
405
|
|
|
406
406
|
## Server-Only Pages
|
|
407
407
|
|
|
408
|
-
You can define a page as [server only](/docs/3.x/
|
|
408
|
+
You can define a page as [server only](/docs/3.x/directory-structure/components#server-components) by giving it a `.server.vue` suffix. While you will be able to navigate to the page using client-side navigation, controlled by `vue-router`, it will be rendered with a server component automatically, meaning the code required to render the page will not be in your client-side bundle.
|
|
409
409
|
|
|
410
410
|
::warning
|
|
411
411
|
Server-only pages must have a single root element. (HTML comments are considered elements as well.)
|
|
@@ -134,7 +134,7 @@ export default defineNuxtPlugin({
|
|
|
134
134
|
|
|
135
135
|
## Using Composables
|
|
136
136
|
|
|
137
|
-
You can use [composables](/docs/3.x/
|
|
137
|
+
You can use [composables](/docs/3.x/directory-structure/composables) as well as [utils](/docs/3.x/directory-structure/utils) within Nuxt plugins:
|
|
138
138
|
|
|
139
139
|
```ts [plugins/hello.ts]
|
|
140
140
|
export default defineNuxtPlugin((nuxtApp) => {
|
|
@@ -200,7 +200,7 @@ const { $hello } = useNuxtApp()
|
|
|
200
200
|
```
|
|
201
201
|
|
|
202
202
|
::important
|
|
203
|
-
Note that we highly recommend using [`composables`](/docs/3.x/
|
|
203
|
+
Note that we highly recommend using [`composables`](/docs/3.x/directory-structure/composables) instead of providing helpers to avoid polluting the global namespace and keep your main bundle entry small.
|
|
204
204
|
::
|
|
205
205
|
|
|
206
206
|
::warning
|
|
@@ -58,7 +58,7 @@ export default defineEventHandler(() => 'Hello World!')
|
|
|
58
58
|
Given the example above, the `/hello` route will be accessible at <http://localhost:3000/hello>.
|
|
59
59
|
|
|
60
60
|
::note
|
|
61
|
-
Note that currently server routes do not support the full functionality of dynamic routes as [pages](/docs/3.x/
|
|
61
|
+
Note that currently server routes do not support the full functionality of dynamic routes as [pages](/docs/3.x/directory-structure/pages#dynamic-routes) do.
|
|
62
62
|
::
|
|
63
63
|
|
|
64
64
|
## Server Middleware
|
|
@@ -41,7 +41,7 @@ export default function (input: string) {
|
|
|
41
41
|
}
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
You can now use [auto-imported](/docs/3.x/
|
|
44
|
+
You can now use [auto-imported](/docs/3.x/directory-structure/shared#auto-imports) utilities in your Nuxt app and `server/` directory.
|
|
45
45
|
|
|
46
46
|
```vue [app.vue]
|
|
47
47
|
<script setup lang="ts">
|
|
@@ -68,7 +68,7 @@ export default defineEventHandler((event) => {
|
|
|
68
68
|
Only files in the `shared/utils/` and `shared/types/` directories will be auto-imported. Files nested within subdirectories of these directories will not be auto-imported unless you add these directories to `imports.dirs` and `nitro.imports.dirs`.
|
|
69
69
|
|
|
70
70
|
::tip
|
|
71
|
-
The way `shared/utils` and `shared/types` auto-imports work and are scanned is identical to the [`composables/`](/docs/3.x/
|
|
71
|
+
The way `shared/utils` and `shared/types` auto-imports work and are scanned is identical to the [`composables/`](/docs/3.x/directory-structure/composables) and [`utils/`](/docs/3.x/directory-structure/utils) directories.
|
|
72
72
|
::
|
|
73
73
|
|
|
74
74
|
:read-more{to="/docs/guide/directory-structure/composables#how-files-are-scanned"}
|
|
@@ -5,7 +5,7 @@ description: Use the utils/ directory to auto-import your utility functions thro
|
|
|
5
5
|
navigation.icon: i-vscode-icons-folder-type-tools
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
The main purpose of the [`utils/` directory](/docs/3.x/
|
|
8
|
+
The main purpose of the [`utils/` directory](/docs/3.x/directory-structure/utils) is to allow a semantic distinction between your Vue composables and other auto-imported utility functions.
|
|
9
9
|
|
|
10
10
|
## Usage
|
|
11
11
|
|
|
@@ -40,10 +40,10 @@ You can now use auto imported utility functions in `.js`, `.ts` and `.vue` files
|
|
|
40
40
|
:link-example{to="/docs/examples/features/auto-imports"}
|
|
41
41
|
|
|
42
42
|
::tip
|
|
43
|
-
The way `utils/` auto-imports work and are scanned is identical to the [`composables/`](/docs/3.x/
|
|
43
|
+
The way `utils/` auto-imports work and are scanned is identical to the [`composables/`](/docs/3.x/directory-structure/composables) directory.
|
|
44
44
|
::
|
|
45
45
|
|
|
46
46
|
::important
|
|
47
47
|
These utils are only available within the Vue part of your app. :br
|
|
48
|
-
Only `server/utils` are auto-imported in the [`server/`](/docs/3.x/
|
|
48
|
+
Only `server/utils` are auto-imported in the [`server/`](/docs/3.x/directory-structure/server#server-utilities) directory.
|
|
49
49
|
::
|
|
@@ -6,7 +6,7 @@ navigation.icon: i-vscode-icons-file-type-dotenv
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
::important
|
|
9
|
-
This file should be added to your [`.gitignore`](/docs/3.x/
|
|
9
|
+
This file should be added to your [`.gitignore`](/docs/3.x/directory-structure/gitignore) file to avoid pushing secrets to your repository.
|
|
10
10
|
::
|
|
11
11
|
|
|
12
12
|
## Dev, Build and Generate Time
|