@nuxt/docs-nightly 4.0.0-29157765.d5350c56 → 4.0.0-29159317.1927782f
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/10.data-fetching.md +1 -1
- package/1.getting-started/18.upgrade.md +6 -2
- package/2.guide/1.concepts/3.rendering.md +1 -1
- package/2.guide/2.directory-structure/1.app/.navigation.yml +5 -0
- package/2.guide/2.directory-structure/{1.pages.md → 1.app/1.pages.md} +1 -1
- package/2.guide/3.going-further/1.experimental-features.md +1 -1
- package/2.guide/4.recipes/1.custom-routing.md +5 -5
- package/3.api/2.composables/use-cookie.md +5 -4
- package/3.api/3.utils/define-page-meta.md +1 -1
- package/3.api/5.kit/11.nitro.md +47 -0
- package/3.api/5.kit/4.autoimports.md +8 -8
- package/3.api/6.nuxt-config.md +20 -22
- package/7.migration/7.component-options.md +1 -1
- package/package.json +1 -1
- /package/2.guide/2.directory-structure/{1.assets.md → 1.app/1.assets.md} +0 -0
- /package/2.guide/2.directory-structure/{1.components.md → 1.app/1.components.md} +0 -0
- /package/2.guide/2.directory-structure/{1.composables.md → 1.app/1.composables.md} +0 -0
- /package/2.guide/2.directory-structure/{1.layouts.md → 1.app/1.layouts.md} +0 -0
- /package/2.guide/2.directory-structure/{1.middleware.md → 1.app/1.middleware.md} +0 -0
- /package/2.guide/2.directory-structure/{1.plugins.md → 1.app/1.plugins.md} +0 -0
- /package/2.guide/2.directory-structure/{1.utils.md → 1.app/1.utils.md} +0 -0
- /package/2.guide/2.directory-structure/{3.app-config.md → 1.app/3.app-config.md} +0 -0
- /package/2.guide/2.directory-structure/{3.app.md → 1.app/3.app.md} +0 -0
- /package/2.guide/2.directory-structure/{3.error.md → 1.app/3.error.md} +0 -0
|
@@ -188,6 +188,10 @@ server/
|
|
|
188
188
|
nuxt.config.ts
|
|
189
189
|
```
|
|
190
190
|
|
|
191
|
+
::note
|
|
192
|
+
With this new structure, the `~` alias now points to the `app/` directory by default (your `srcDir`). This means `~/components` resolves to `app/components/`, `~/pages` to `app/pages/`, etc.
|
|
193
|
+
::
|
|
194
|
+
|
|
191
195
|
</details>
|
|
192
196
|
|
|
193
197
|
👉 For more details, see the [PR implementing this change](https://github.com/nuxt/nuxt/pull/27029).
|
|
@@ -218,7 +222,7 @@ You can also force a v3 folder structure with the following configuration:
|
|
|
218
222
|
export default defineNuxtConfig({
|
|
219
223
|
// This reverts the new srcDir default from `app` back to your root directory
|
|
220
224
|
srcDir: '.',
|
|
221
|
-
// This specifies the directory prefix for `
|
|
225
|
+
// This specifies the directory prefix for `router.options.ts` and `spa-loading-template.html`
|
|
222
226
|
dir: {
|
|
223
227
|
app: 'app'
|
|
224
228
|
}
|
|
@@ -430,7 +434,7 @@ export default defineNuxtConfig({
|
|
|
430
434
|
|
|
431
435
|
#### What Changed
|
|
432
436
|
|
|
433
|
-
When rendering a client-only page (with `ssr: false`), we optionally render a loading screen (from
|
|
437
|
+
When rendering a client-only page (with `ssr: false`), we optionally render a loading screen (from `~/app/spa-loading-template.html` - note that this has also changed to `~/spa-loading-template.html` in Nuxt 4), within the Nuxt app root:
|
|
434
438
|
|
|
435
439
|
```html
|
|
436
440
|
<div id="__nuxt">
|
|
@@ -88,7 +88,7 @@ export default defineNuxtConfig({
|
|
|
88
88
|
```
|
|
89
89
|
|
|
90
90
|
::note
|
|
91
|
-
If you do use `ssr: false`, you should also place an HTML file in `~/
|
|
91
|
+
If you do use `ssr: false`, you should also place an HTML file in `~/spa-loading-template.html` with some HTML you would like to use to render a loading screen that will be rendered until your app is hydrated.
|
|
92
92
|
:read-more{title="SPA Loading Template" to="/docs/api/configuration/nuxt-config#spaloadingtemplate"}
|
|
93
93
|
::
|
|
94
94
|
|
|
@@ -6,7 +6,7 @@ navigation.icon: i-lucide-folder
|
|
|
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/guide/directory-structure/app). To force the pages system, set `pages: true` in `nuxt.config` or have a [`
|
|
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/guide/directory-structure/app). To force the pages system, set `pages: true` in `nuxt.config` or have a [`router.options.ts`](/docs/guide/recipes/custom-routing#using-approuteroptions).
|
|
10
10
|
::
|
|
11
11
|
|
|
12
12
|
## Usage
|
|
@@ -454,7 +454,7 @@ By setting `experimental.normalizeComponentNames`, these two values match, and V
|
|
|
454
454
|
|
|
455
455
|
## spaLoadingTemplateLocation
|
|
456
456
|
|
|
457
|
-
When rendering a client-only page (with `ssr: false`), we optionally render a loading screen (from
|
|
457
|
+
When rendering a client-only page (with `ssr: false`), we optionally render a loading screen (from `~/spa-loading-template.html`).
|
|
458
458
|
|
|
459
459
|
It can be set to `within`, which will render it like this:
|
|
460
460
|
|
|
@@ -13,7 +13,7 @@ Using [router options](/docs/guide/recipes/custom-routing#router-options), you c
|
|
|
13
13
|
|
|
14
14
|
If it returns `null` or `undefined`, Nuxt will fall back to the default routes (useful to modify input array).
|
|
15
15
|
|
|
16
|
-
```ts [
|
|
16
|
+
```ts [router.options.ts]
|
|
17
17
|
import type { RouterConfig } from '@nuxt/schema'
|
|
18
18
|
|
|
19
19
|
export default {
|
|
@@ -83,11 +83,11 @@ The [Nuxt kit](/docs/guide/going-further/kit) provides a few ways [to add routes
|
|
|
83
83
|
|
|
84
84
|
On top of customizing options for [`vue-router`](https://router.vuejs.org/api/interfaces/routeroptions.html), Nuxt offers [additional options](/docs/api/nuxt-config#router) to customize the router.
|
|
85
85
|
|
|
86
|
-
### Using `
|
|
86
|
+
### Using `router.options`
|
|
87
87
|
|
|
88
88
|
This is the recommended way to specify [router options](/docs/api/nuxt-config#router).
|
|
89
89
|
|
|
90
|
-
```ts [
|
|
90
|
+
```ts [router.options.ts]
|
|
91
91
|
import type { RouterConfig } from '@nuxt/schema'
|
|
92
92
|
|
|
93
93
|
export default {
|
|
@@ -109,7 +109,7 @@ export default defineNuxtConfig({
|
|
|
109
109
|
const resolver = createResolver(import.meta.url)
|
|
110
110
|
// add a route
|
|
111
111
|
files.push({
|
|
112
|
-
path: resolver.resolve('./runtime/
|
|
112
|
+
path: resolver.resolve('./runtime/router-options'),
|
|
113
113
|
optional: true
|
|
114
114
|
})
|
|
115
115
|
}
|
|
@@ -170,7 +170,7 @@ export default defineNuxtConfig({
|
|
|
170
170
|
|
|
171
171
|
You can optionally override history mode using a function that accepts the base URL and returns the history mode. If it returns `null` or `undefined`, Nuxt will fallback to the default history.
|
|
172
172
|
|
|
173
|
-
```ts [
|
|
173
|
+
```ts [router.options.ts]
|
|
174
174
|
import type { RouterConfig } from '@nuxt/schema'
|
|
175
175
|
import { createMemoryHistory } from 'vue-router'
|
|
176
176
|
|
|
@@ -168,8 +168,9 @@ const user = useCookie(
|
|
|
168
168
|
}
|
|
169
169
|
)
|
|
170
170
|
|
|
171
|
-
if (user.value
|
|
172
|
-
|
|
171
|
+
if (user.value) {
|
|
172
|
+
// the actual `userInfo` cookie will not be updated
|
|
173
|
+
user.value.score++
|
|
173
174
|
}
|
|
174
175
|
</script>
|
|
175
176
|
|
|
@@ -196,9 +197,9 @@ function add() {
|
|
|
196
197
|
}
|
|
197
198
|
|
|
198
199
|
function save() {
|
|
199
|
-
if (list.value
|
|
200
|
+
if (list.value) {
|
|
201
|
+
// the actual `list` cookie will be updated
|
|
200
202
|
list.value = [...list.value]
|
|
201
|
-
// list cookie update with this change
|
|
202
203
|
}
|
|
203
204
|
}
|
|
204
205
|
</script>
|
|
@@ -136,7 +136,7 @@ interface PageMeta {
|
|
|
136
136
|
|
|
137
137
|
- **Type**: `boolean | (to: RouteLocationNormalized, from: RouteLocationNormalized) => boolean`
|
|
138
138
|
|
|
139
|
-
Tell Nuxt to scroll to the top before rendering the page or not. If you want to overwrite the default scroll behavior of Nuxt, you can do so in `~/
|
|
139
|
+
Tell Nuxt to scroll to the top before rendering the page or not. If you want to overwrite the default scroll behavior of Nuxt, you can do so in `~/router.options.ts` (see [custom routing](/docs/guide/recipes/custom-routing#using-approuteroptions)) for more info.
|
|
140
140
|
|
|
141
141
|
**`[key: string]`**
|
|
142
142
|
|
package/3.api/5.kit/11.nitro.md
CHANGED
|
@@ -293,6 +293,53 @@ function addPrerenderRoutes (routes: string | string[]): void
|
|
|
293
293
|
| ----------- | ------------------------------- | -------- | ---------------------------------------------- |
|
|
294
294
|
| `routes` | `string \| string[]`{lang="ts"} | `true` | A route or an array of routes to prerender. |
|
|
295
295
|
|
|
296
|
+
## `addServerImports`
|
|
297
|
+
|
|
298
|
+
Add imports to the server. It makes your imports available in Nitro without the need to import them manually.
|
|
299
|
+
|
|
300
|
+
### Usage
|
|
301
|
+
|
|
302
|
+
```ts twoslash
|
|
303
|
+
import { defineNuxtModule, createResolver, addServerImports } from '@nuxt/kit'
|
|
304
|
+
|
|
305
|
+
export default defineNuxtModule({
|
|
306
|
+
setup(options) {
|
|
307
|
+
const names = [
|
|
308
|
+
'useStoryblok',
|
|
309
|
+
'useStoryblokApi',
|
|
310
|
+
'useStoryblokBridge',
|
|
311
|
+
'renderRichText',
|
|
312
|
+
'RichTextSchema'
|
|
313
|
+
]
|
|
314
|
+
|
|
315
|
+
names.forEach((name) =>
|
|
316
|
+
addServerImports({ name, as: name, from: '@storyblok/vue' })
|
|
317
|
+
)
|
|
318
|
+
}
|
|
319
|
+
})
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Type
|
|
323
|
+
|
|
324
|
+
```ts
|
|
325
|
+
function addServerImports (dirs: Import | Import[]): void
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### Parameters
|
|
329
|
+
|
|
330
|
+
`imports`: An object or an array of objects with the following properties:
|
|
331
|
+
|
|
332
|
+
| Property | Type | Required | Description |
|
|
333
|
+
| ------------------ | ---------------------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
|
|
334
|
+
| `name` | `string` | `true` | Import name to be detected. |
|
|
335
|
+
| `from` | `string` | `true` | Module specifier to import from. |
|
|
336
|
+
| `priority` | `number` | `false` | Priority of the import; if multiple imports have the same name, the one with the highest priority will be used. |
|
|
337
|
+
| `disabled` | `boolean` | `false` | If this import is disabled. |
|
|
338
|
+
| `meta` | `Record<string, any>` | `false` | Metadata of the import. |
|
|
339
|
+
| `type` | `boolean` | `false` | If this import is a pure type import. |
|
|
340
|
+
| `typeFrom` | `string` | `false` | Use this as the `from` value when generating type declarations. |
|
|
341
|
+
| `as` | `string` | `false` | Import as this name. |
|
|
342
|
+
|
|
296
343
|
## `addServerImportsDir`
|
|
297
344
|
|
|
298
345
|
Add a directory to be scanned for auto-imports by Nitro.
|
|
@@ -34,16 +34,16 @@ import { defineNuxtModule, addImports } from "@nuxt/kit";
|
|
|
34
34
|
export default defineNuxtModule({
|
|
35
35
|
setup(options, nuxt) {
|
|
36
36
|
const names = [
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
]
|
|
37
|
+
'useStoryblok',
|
|
38
|
+
'useStoryblokApi',
|
|
39
|
+
'useStoryblokBridge',
|
|
40
|
+
'renderRichText',
|
|
41
|
+
'RichTextSchema'
|
|
42
|
+
]
|
|
43
43
|
|
|
44
44
|
names.forEach((name) =>
|
|
45
|
-
addImports({ name, as: name, from:
|
|
46
|
-
)
|
|
45
|
+
addImports({ name, as: name, from: '@storyblok/vue' })
|
|
46
|
+
)
|
|
47
47
|
}
|
|
48
48
|
})
|
|
49
49
|
```
|
package/3.api/6.nuxt-config.md
CHANGED
|
@@ -1793,7 +1793,7 @@ Additional router options passed to `vue-router`. On top of the options for `vue
|
|
|
1793
1793
|
|
|
1794
1794
|
::callout
|
|
1795
1795
|
**Note**: Only JSON serializable options should be passed by Nuxt config.
|
|
1796
|
-
For more control, you can use `
|
|
1796
|
+
For more control, you can use an `router.options.ts` file.
|
|
1797
1797
|
::
|
|
1798
1798
|
|
|
1799
1799
|
**See**: [Vue Router documentation](https://router.vuejs.org/api/interfaces/routeroptions.html).
|
|
@@ -1902,13 +1902,13 @@ Available options for both client and server: - `true`: Generates sourcemaps and
|
|
|
1902
1902
|
|
|
1903
1903
|
Boolean or a path to an HTML file with the contents of which will be inserted into any HTML page rendered with `ssr: false`.
|
|
1904
1904
|
|
|
1905
|
-
- If it is unset, it will use `~/
|
|
1905
|
+
- If it is unset, it will use `~/spa-loading-template.html` file in one of your layers, if it exists. - If it is false, no SPA loading indicator will be loaded. - If true, Nuxt will look for `~/spa-loading-template.html` file in one of your layers, or a
|
|
1906
1906
|
default Nuxt image will be used.
|
|
1907
1907
|
Some good sources for spinners are [SpinKit](https://github.com/tobiasahlin/SpinKit) or [SVG Spinners](https://icones.js.org/collection/svg-spinners).
|
|
1908
1908
|
|
|
1909
1909
|
- **Default:** `null`
|
|
1910
1910
|
|
|
1911
|
-
**Example**: ~/
|
|
1911
|
+
**Example**: ~/spa-loading-template.html
|
|
1912
1912
|
```html
|
|
1913
1913
|
<!-- https://github.com/barelyhuman/snips/blob/dev/pages/css-loader.md -->
|
|
1914
1914
|
<div class="loader"></div>
|
|
@@ -1959,33 +1959,31 @@ Define the source directory of your Nuxt application.
|
|
|
1959
1959
|
If a relative path is specified, it will be relative to the `rootDir`.
|
|
1960
1960
|
|
|
1961
1961
|
- **Type**: `string`
|
|
1962
|
-
- **Default:** `"
|
|
1962
|
+
- **Default:** `"app"` (Nuxt 4), `"."` (Nuxt 3 with `compatibilityMode: 3`)
|
|
1963
1963
|
|
|
1964
1964
|
**Example**:
|
|
1965
1965
|
```js
|
|
1966
1966
|
export default {
|
|
1967
|
-
srcDir: '
|
|
1967
|
+
srcDir: 'app/'
|
|
1968
1968
|
}
|
|
1969
1969
|
```
|
|
1970
|
-
This
|
|
1970
|
+
This expects the following folder structure:
|
|
1971
1971
|
```bash
|
|
1972
1972
|
-| app/
|
|
1973
|
-
---|
|
|
1974
|
-
---|
|
|
1975
|
-
---|
|
|
1976
|
-
---|
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
------| app.vue
|
|
1988
|
-
------| error.vue
|
|
1973
|
+
---| assets/
|
|
1974
|
+
---| components/
|
|
1975
|
+
---| layouts/
|
|
1976
|
+
---| middleware/
|
|
1977
|
+
---| pages/
|
|
1978
|
+
---| plugins/
|
|
1979
|
+
---| app.config.ts
|
|
1980
|
+
---| app.vue
|
|
1981
|
+
---| error.vue
|
|
1982
|
+
-| server/
|
|
1983
|
+
-| public/
|
|
1984
|
+
-| modules/
|
|
1985
|
+
-| nuxt.config.js
|
|
1986
|
+
-| package.json
|
|
1989
1987
|
```
|
|
1990
1988
|
|
|
1991
1989
|
## ssr
|
|
@@ -103,7 +103,7 @@ This feature is not yet supported in Nuxt 3.
|
|
|
103
103
|
|
|
104
104
|
## `scrollToTop`
|
|
105
105
|
|
|
106
|
-
This feature is not yet supported in Nuxt 3. If you want to overwrite the default scroll behavior of `vue-router`, you can do so in `~/
|
|
106
|
+
This feature is not yet supported in Nuxt 3. If you want to overwrite the default scroll behavior of `vue-router`, you can do so in an `~/router.options.ts` (see [docs](/docs/guide/recipes/custom-routing#router-options)) for more info.
|
|
107
107
|
Similar to `key`, specify it within the [`definePageMeta`](/docs/api/utils/define-page-meta) compiler macro.
|
|
108
108
|
|
|
109
109
|
```diff [pages/index.vue]
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|