@nuxt/docs-nightly 4.0.1-29211316.5018ed23 → 4.0.1-29212698.365e81c1

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.
@@ -24,7 +24,7 @@ Nuxt uses conventions and an opinionated directory structure to automate repetit
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.
26
26
  - **Data-fetching utilities:** Nuxt provides composables to handle SSR-compatible data fetching as well as different strategies.
27
- - **Zero-config TypeScript support:** write type-safe code without having to learn TypeScript with our auto-generated types and `tsconfig.json`
27
+ - **Zero-config TypeScript support:** write type-safe code without having to learn TypeScript with our auto-generated types and `tsconfig.json`.
28
28
  - **Configured build tools:** we use [Vite](https://vite.dev) by default to support hot module replacement (HMR) in development and bundling your code for production with best-practices baked-in.
29
29
 
30
30
  Nuxt takes care of these and provides both frontend and backend functionality so you can focus on what matters: **creating your web application**.
@@ -64,7 +64,7 @@ A Nuxt application can be deployed on a Node or Deno server, pre-rendered to be
64
64
 
65
65
  ### Modular
66
66
 
67
- A module system allows to extend Nuxt with custom features and integrations with third-party services.
67
+ A module system allows you to extend Nuxt with custom features and integrations with third-party services.
68
68
 
69
69
  :read-more{title="Nuxt Modules Concept" to="/docs/guide/concepts/modules"}
70
70
 
@@ -100,7 +100,7 @@ const runtimeConfig = useRuntimeConfig()
100
100
 
101
101
  ## App Configuration
102
102
 
103
- The `app.config.ts` file, located in the source directory (by default the root of the project), is used to expose public variables that can be determined at build time. Contrary to the `runtimeConfig` option, these can not be overridden using environment variables.
103
+ The `app.config.ts` file, located in the source directory (by default the root of the project), is used to expose public variables that can be determined at build time. Contrary to the `runtimeConfig` option, these cannot be overridden using environment variables.
104
104
 
105
105
  A minimal configuration file exports the `defineAppConfig` function containing an object with your configuration. The `defineAppConfig` helper is globally available without import.
106
106
 
@@ -88,7 +88,7 @@ To use pages, create `pages/index.vue` file and add `<NuxtPage />` component to
88
88
 
89
89
  ![Layouts are wrapper around pages](/assets/docs/getting-started/views/layouts.svg)
90
90
 
91
- Layouts are wrappers around pages that contain a common User Interface for several pages, such as a header and footer display. 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.
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
94
  If you only have a single layout in your application, we recommend using [`app.vue`](/docs/guide/directory-structure/app) with [`<NuxtPage />`](/docs/api/components/nuxt-page) instead.
@@ -119,7 +119,7 @@ export default defineNuxtConfig({
119
119
 
120
120
  ## External Stylesheets
121
121
 
122
- You can include external stylesheets in your application by adding a link element in the head section of your nuxt.config file. You can achieve this result using different methods. Note that local stylesheets can also be included like this.
122
+ You can include external stylesheets in your application by adding a link element in the head section of your nuxt.config file. You can achieve this result using different methods. Note that local stylesheets can also be included this way.
123
123
 
124
124
  You can manipulate the head with the [`app.head`](/docs/api/nuxt-config#head) property of your Nuxt configuration:
125
125
 
@@ -409,7 +409,7 @@ You can use [CSS Modules](https://github.com/css-modules/css-modules) with the m
409
409
 
410
410
  ### Preprocessors Support
411
411
 
412
- SFC style blocks support preprocessors syntax. Vite come with built-in support for .scss, .sass, .less, .styl and .stylus files without configuration. You just need to install them first, and they will be available directly in SFC with the lang attribute.
412
+ SFC style blocks support preprocessor syntax. Vite comes with built-in support for .scss, .sass, .less, .styl and .stylus files without configuration. You just need to install them first, and they will be available directly in SFC with the lang attribute.
413
413
 
414
414
  ::code-group
415
415
 
@@ -12,7 +12,7 @@ and numerous configuration options to manage your app's head and SEO meta tags.
12
12
  Providing an [`app.head`](/docs/api/nuxt-config#head) property in your [`nuxt.config.ts`](/docs/guide/directory-structure/nuxt-config) allows you to statically customize the head for your entire app.
13
13
 
14
14
  ::important
15
- This method does not allow you to provide reactive data. We recommend to use `useHead()` in `app.vue`.
15
+ This method does not allow you to provide reactive data. We recommend using `useHead()` in `app.vue`.
16
16
  ::
17
17
 
18
18
  It's good practice to set tags here that won't change such as your site title default, language and favicon.
@@ -75,7 +75,7 @@ useHead({
75
75
  </script>
76
76
  ```
77
77
 
78
- We recommend to take a look at the [`useHead`](/docs/api/composables/use-head) and [`useHeadSafe`](/docs/api/composables/use-head-safe) composables.
78
+ We recommend taking a look at the [`useHead`](/docs/api/composables/use-head) and [`useHeadSafe`](/docs/api/composables/use-head-safe) composables.
79
79
 
80
80
  ## `useSeoMeta`
81
81
 
@@ -16,7 +16,7 @@ You can enable page transitions to apply an automatic transition for all your [p
16
16
  export default defineNuxtConfig({
17
17
  app: {
18
18
  pageTransition: { name: 'page', mode: 'out-in' }
19
- },
19
+ }
20
20
  })
21
21
  ```
22
22
 
@@ -121,7 +121,7 @@ You can enable layout transitions to apply an automatic transition for all your
121
121
  export default defineNuxtConfig({
122
122
  app: {
123
123
  layoutTransition: { name: 'layout', mode: 'out-in' }
124
- },
124
+ }
125
125
  })
126
126
  ```
127
127
 
@@ -470,4 +470,4 @@ export default defineNuxtRouteMiddleware(to => {
470
470
 
471
471
  ### Known Issues
472
472
 
473
- - If you perform data fetching within your page setup functions, that you may wish to reconsider using this feature for the moment. (By design, View Transitions completely freeze DOM updates whilst they are taking place.) We're looking at restrict the View Transition to the final moments before `<Suspense>` resolves, but in the interim you may want to consider carefully whether to adopt this feature if this describes you.
473
+ - If you perform data fetching within your page setup functions, you may wish to reconsider using this feature for the moment. (By design, View Transitions completely freeze DOM updates whilst they are taking place.) We're looking at restricting the View Transition to the final moments before `<Suspense>` resolves, but in the interim you may want to consider carefully whether to adopt this feature if this describes you.
@@ -9,7 +9,7 @@ Nuxt comes with two composables and a built-in library to perform data-fetching
9
9
  In a nutshell:
10
10
 
11
11
  - [`$fetch`](/docs/api/utils/dollarfetch) is the simplest way to make a network request.
12
- - [`useFetch`](/docs/api/composables/use-fetch) is wrapper around `$fetch` that fetches data only once in [universal rendering](/docs/guide/concepts/rendering#universal-rendering).
12
+ - [`useFetch`](/docs/api/composables/use-fetch) is a wrapper around `$fetch` that fetches data only once in [universal rendering](/docs/guide/concepts/rendering#universal-rendering).
13
13
  - [`useAsyncData`](/docs/api/composables/use-async-data) is similar to `useFetch` but offers more fine-grained control.
14
14
 
15
15
  Both `useFetch` and `useAsyncData` share a common set of options and patterns that we will detail in the last sections.
@@ -81,7 +81,7 @@ async function addTodo() {
81
81
 
82
82
  ::warning
83
83
  Beware that using only `$fetch` will not provide [network calls de-duplication and navigation prevention](#the-need-for-usefetch-and-useasyncdata). :br
84
- It is recommended to use `$fetch` for client-side interactions (event based) or combined with [`useAsyncData`](#useasyncdata) when fetching the initial component data.
84
+ It is recommended to use `$fetch` for client-side interactions (event-based) or combined with [`useAsyncData`](#useasyncdata) when fetching the initial component data.
85
85
  ::
86
86
 
87
87
  ::read-more{to="/docs/api/utils/dollarfetch"}
@@ -483,7 +483,7 @@ If you need to change the URL based on a reactive value, you may want to use a [
483
483
 
484
484
  #### Computed URL
485
485
 
486
- Sometimes you may need to compute an URL from reactive values, and refresh the data each time these change. Instead of juggling your way around, you can attach each param as a reactive value. Nuxt will automatically use the reactive value and re-fetch each time it changes.
486
+ Sometimes you may need to compute a URL from reactive values, and refresh the data each time these change. Instead of juggling your way around, you can attach each param as a reactive value. Nuxt will automatically use the reactive value and re-fetch each time it changes.
487
487
 
488
488
  ```vue
489
489
  <script setup lang="ts">
@@ -109,7 +109,7 @@ const handleError = () => clearError({ redirect: '/' })
109
109
  Read more about `error.vue` and its uses.
110
110
  ::
111
111
 
112
- For custom errors we highly recommend to use `onErrorCaptured` composable that can be called in a page/component setup function or `vue:error` runtime nuxt hook that can be configured in a nuxt plugin.
112
+ For custom errors we highly recommend using `onErrorCaptured` composable that can be called in a page/component setup function or `vue:error` runtime nuxt hook that can be configured in a nuxt plugin.
113
113
 
114
114
  ```ts twoslash [plugins/error-handler.ts]
115
115
  export default defineNuxtPlugin(nuxtApp => {
@@ -177,7 +177,7 @@ export default defineNuxtConfig({
177
177
 
178
178
  ### `prerender:generate` Nitro hook
179
179
 
180
- This is called for each route during prerendering. You can use this for fine grained handling of each route that gets prerendered.
180
+ This is called for each route during prerendering. You can use this for fine-grained handling of each route that gets prerendered.
181
181
 
182
182
  ```ts [nuxt.config.ts]
183
183
  export default defineNuxtConfig({
@@ -63,7 +63,7 @@ We currently ship an environment for unit testing code that needs a [Nuxt](https
63
63
 
64
64
  ::tip
65
65
  When importing `@nuxt/test-utils` in your vitest config, It is necessary to have `"type": "module"` specified in your `package.json` or rename your vitest config file appropriately.
66
- > ie. `vitest.config.m{ts,js}`.
66
+ > i.e., `vitest.config.m{ts,js}`.
67
67
  ::
68
68
 
69
69
  ::tip
@@ -431,7 +431,7 @@ export default defineNuxtPlugin({
431
431
  })
432
432
  ```
433
433
 
434
- While not required it's recommend to update any imports from `@unhead/vue` to `#imports` or `nuxt/app`.
434
+ While not required it's recommended to update any imports from `@unhead/vue` to `#imports` or `nuxt/app`.
435
435
 
436
436
  ```diff
437
437
  -import { useHead } from '@unhead/vue'
@@ -975,7 +975,41 @@ const importName = genSafeVariableName
975
975
  You can automate this step by running `npx codemod@latest nuxt/4/template-compilation-changes`
976
976
  ::
977
977
 
978
- ### TypeScript Configuration Changes
978
+ ### Default TypeScript Configuration Changes
979
+
980
+ 🚦 **Impact Level**: Minimal
981
+
982
+ #### What Changed
983
+
984
+ `compilerOptions.noUncheckedIndexedAccess` is now `true` instead of `false`.
985
+
986
+ #### Reasons for Change
987
+
988
+ This change is a follow up to a prior [3.12 config update](https://github.com/nuxt/nuxt/pull/27485) where we improved our defaults, mostly adhering to [TotalTypeScript's recommendations](https://www.totaltypescript.com/tsconfig-cheat-sheet).
989
+
990
+ #### Migration Steps
991
+
992
+ There are two approaches:
993
+
994
+ 1. Run a typecheck on your app and fix any new errors (recommended).
995
+
996
+ 2. Override the new default in your `nuxt.config.ts`:
997
+
998
+ <!-- @case-police-ignore tsConfig -->
999
+
1000
+ ```ts
1001
+ export default defineNuxtConfig({
1002
+ typescript: {
1003
+ tsConfig: {
1004
+ compilerOptions: {
1005
+ noUncheckedIndexedAccess: false
1006
+ }
1007
+ }
1008
+ }
1009
+ })
1010
+ ```
1011
+
1012
+ ### TypeScript Configuration Splitting
979
1013
 
980
1014
  🚦 **Impact Level**: Minimal
981
1015
 
@@ -70,7 +70,7 @@ Out of the box, a traditional Vue.js application is rendered in the browser (or
70
70
 
71
71
  **Benefits of client-side rendering:**
72
72
  - **Development speed**: When working entirely on the client-side, we don't have to worry about the server compatibility of the code, for example, by using browser-only APIs like the `window` object.
73
- - **Cheaper:** Running a server adds a cost of infrastructure as you would need to run on a platform that supports JavaScript. We can host Client-only applications on any static server with HTML, CSS, and JavaScript files.
73
+ - **Cheaper:** Running a server adds a cost of infrastructure as you would need to run on a platform that supports JavaScript. We can host client-only applications on any static server with HTML, CSS, and JavaScript files.
74
74
  - **Offline:** Because code entirely runs in the browser, it can nicely keep working while the internet is unavailable.
75
75
 
76
76
  **Downsides of client-side rendering:**
@@ -79,7 +79,7 @@ const MyButton = resolveComponent('MyButton')
79
79
  ```
80
80
 
81
81
  ::important
82
- If you are using `resolveComponent` to handle dynamic components, make sure not to insert anything but the name of the component, which must be a literal string and not be or contain a variable. The string is statically analyzed at compilation step.
82
+ If you are using `resolveComponent` to handle dynamic components, make sure not to insert anything but the name of the component, which must be a literal string and not be or contain a variable. The string is statically analyzed at the compilation step.
83
83
  ::
84
84
 
85
85
  :video-accordion{title="Watch Daniel Roe's short video about resolveComponent()" videoId="4kq8E5IUM2U"}
@@ -377,7 +377,7 @@ Learn more about `<NuxtLink>` usage.
377
377
  Nuxt allows programmatic navigation through the `navigateTo()` utility method. Using this utility method, you will be able to programmatically navigate the user in your app. This is great for taking input from the user and navigating them dynamically throughout your application. In this example, we have a simple method called `navigate()` that gets called when the user submits a search form.
378
378
 
379
379
  ::note
380
- Ensure to always `await` on `navigateTo` or chain its result by returning from functions.
380
+ Make sure to always `await` on `navigateTo` or chain its result by returning from functions.
381
381
  ::
382
382
 
383
383
  ```vue twoslash
@@ -813,7 +813,7 @@ Watch Vue School video about Nuxt module types.
813
813
 
814
814
  **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.
815
815
 
816
- **Third party and other community modules** are modules (often) prefixed with `nuxt-`. Anyone can make them, using this prefix allows these modules to be discoverable on npm. This is the best starting point to draft and try an idea!
816
+ **Third-party and other community modules** are modules (often) prefixed with `nuxt-`. Anyone can make them, using this prefix allows these modules to be discoverable on npm. This is the best starting point to draft and try an idea!
817
817
 
818
818
  **Private or personal modules** are modules made for your own use case or company. They don't need to follow any naming rules to work with Nuxt and are often seen scoped under an npm organization (e.g. `@my-company/nuxt-auth`)
819
819
 
@@ -15,7 +15,7 @@ This composable is available in Nuxt v3.14+.
15
15
  You can use the built-in [`useResponseHeader`](/docs/api/composables/use-response-header) composable to set any server response header within your pages, components, and plugins.
16
16
 
17
17
  ```ts
18
- // Set the a custom response header
18
+ // Set a custom response header
19
19
  const header = useResponseHeader('X-My-Header');
20
20
  header.value = 'my-value';
21
21
  ```
@@ -20,7 +20,7 @@ Using `$fetch` in components without wrapping it with [`useAsyncData`](/docs/api
20
20
 
21
21
  ## Usage
22
22
 
23
- We recommend to use [`useFetch`](/docs/api/composables/use-fetch) or [`useAsyncData`](/docs/api/composables/use-async-data) + `$fetch` to prevent double data fetching when fetching the component data.
23
+ We recommend using [`useFetch`](/docs/api/composables/use-fetch) or [`useAsyncData`](/docs/api/composables/use-async-data) + `$fetch` to prevent double data fetching when fetching the component data.
24
24
 
25
25
  ```vue [app.vue]
26
26
  <script setup lang="ts">
@@ -8,7 +8,7 @@ links:
8
8
  size: xs
9
9
  ---
10
10
 
11
- Templates allows to generate extra files during development and build time. These files will be available in virtual filesystem and can be used in plugins, layouts, components, etc. `addTemplate` and `addTypeTemplate` allow you to add templates to the Nuxt application. `updateTemplates` allows you to regenerate templates that match the filter.
11
+ Templates allow you to generate extra files during development and build time. These files will be available in virtual filesystem and can be used in plugins, layouts, components, etc. `addTemplate` and `addTypeTemplate` allow you to add templates to the Nuxt application. `updateTemplates` allows you to regenerate templates that match the filter.
12
12
 
13
13
  ## `addTemplate`
14
14
 
@@ -74,13 +74,13 @@ Hook | Arguments | Description
74
74
  `schema:resolved` | `schema` | Allows extending resolved schema.
75
75
  `schema:beforeWrite` | `schema` | Called before writing the given schema.
76
76
  `schema:written` | - | Called after the schema is written.
77
- `vite:extend` | `viteBuildContext` | Allows to extend Vite default context.
78
- `vite:extendConfig` | `viteInlineConfig, env` | Allows to extend Vite default config.
79
- `vite:configResolved` | `viteInlineConfig, env` | Allows to read the resolved Vite config.
77
+ `vite:extend` | `viteBuildContext` | Allows extending Vite default context.
78
+ `vite:extendConfig` | `viteInlineConfig, env` | Allows extending Vite default config.
79
+ `vite:configResolved` | `viteInlineConfig, env` | Allows reading the resolved Vite config.
80
80
  `vite:serverCreated` | `viteServer, env` | Called when the Vite server is created.
81
81
  `vite:compiled` | - | Called after Vite server is compiled.
82
82
  `webpack:config` | `webpackConfigs` | Called before configuring the webpack compiler.
83
- `webpack:configResolved` | `webpackConfigs` | Allows to read the resolved webpack config.
83
+ `webpack:configResolved` | `webpackConfigs` | Allows reading the resolved webpack config.
84
84
  `webpack:compile` | `options` | Called right before compilation.
85
85
  `webpack:compiled` | `options` | Called after resources are loaded.
86
86
  `webpack:change` | `shortPath` | Called on `change` on WebpackBar.
@@ -37,13 +37,15 @@ your alias by prefixing it with `~`.
37
37
 
38
38
  **Example**:
39
39
  ```js
40
- export default {
40
+ import { fileURLToPath } from "node:url";
41
+
42
+ export default defineNuxtConfig({
41
43
  alias: {
42
44
  'images': fileURLToPath(new URL('./assets/images', import.meta.url)),
43
45
  'style': fileURLToPath(new URL('./assets/style', import.meta.url)),
44
46
  'data': fileURLToPath(new URL('./assets/other/data', import.meta.url))
45
47
  }
46
- }
48
+ })
47
49
  ```
48
50
 
49
51
  ```html
@@ -814,7 +816,7 @@ export default defineNuxtConfig({
814
816
 
815
817
  ### `decorators`
816
818
 
817
- Enable to use experimental decorators in Nuxt and Nitro.
819
+ Enable the use of experimental decorators in Nuxt and Nitro.
818
820
 
819
821
  - **Type**: `boolean`
820
822
  - **Default:** `false`
@@ -193,7 +193,7 @@ Most of the syntax and functionality are the same for the global [NuxtLink](/doc
193
193
  When migrating from Nuxt 2 to Nuxt 3, you will have to update how you programmatically navigate your users. In Nuxt 2, you had access to the underlying Vue Router with `this.$router`. In Nuxt 3, you can use the `navigateTo()` utility method which allows you to pass a route and parameters to Vue Router.
194
194
 
195
195
  ::warning
196
- Ensure to always `await` on [`navigateTo`](/docs/api/utils/navigate-to) or chain its result by returning from functions.
196
+ Make sure to always `await` on [`navigateTo`](/docs/api/utils/navigate-to) or chain its result by returning from functions.
197
197
  ::
198
198
 
199
199
  ::code-group
@@ -27,7 +27,7 @@ export default defineNuxtConfig({
27
27
  public: {
28
28
  apiBase: '/api'
29
29
  }
30
- },
30
+ }
31
31
  })
32
32
  ```
33
33
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/docs-nightly",
3
- "version": "4.0.1-29211316.5018ed23",
3
+ "version": "4.0.1-29212698.365e81c1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",