+
+
+
+
+```
+
## Isomorphic fetch
When we call `fetch` in the browser, user headers like `cookie` will be directly sent to the API. But during server-side-rendering, since the `fetch` request takes place 'internally' within the server, it doesn't include the user's browser cookies, nor does it pass on cookies from the fetch response.
diff --git a/examples/use-async-data/app.vue b/examples/use-async-data/app.vue
index fa1a0be39d6..6cf95b41d6d 100644
--- a/examples/use-async-data/app.vue
+++ b/examples/use-async-data/app.vue
@@ -1,18 +1,35 @@
-
{{ data }}
-
- Refresh Data
-
-
- +
-
+
+
+ {{ showMountain ? 'Hide' : 'Show' }} Mountain
+
+
+ Refetch All Data
+
+
+
diff --git a/packages/bridge/src/runtime/composables.ts b/packages/bridge/src/runtime/composables.ts
index 4fa9ef40f25..190511a6b5a 100644
--- a/packages/bridge/src/runtime/composables.ts
+++ b/packages/bridge/src/runtime/composables.ts
@@ -8,7 +8,7 @@ import { sendRedirect } from 'h3'
import defu from 'defu'
import { useNuxtApp } from './app'
-export { useLazyAsyncData } from './asyncData'
+export { useLazyAsyncData, refreshNuxtData } from './asyncData'
export { useLazyFetch } from './fetch'
export { useCookie } from './cookie'
export { useRequestHeaders } from './ssr'
diff --git a/packages/nuxt3/src/app/composables/asyncData.ts b/packages/nuxt3/src/app/composables/asyncData.ts
index 38a4da50397..ae164d346ea 100644
--- a/packages/nuxt3/src/app/composables/asyncData.ts
+++ b/packages/nuxt3/src/app/composables/asyncData.ts
@@ -137,12 +137,15 @@ export function useAsyncData<
asyncData.refresh()
}
if (options.watch) {
- const unwatch = watch(options.watch, () => {
- asyncData.refresh()
- })
- if (instance) {
- onUnmounted(() => unwatch())
+ watch(options.watch, () => asyncData.refresh())
+ }
+ const off = nuxt.hook('app:data:refresh', (keys) => {
+ if (!keys || keys.includes(key)) {
+ return asyncData.refresh()
}
+ })
+ if (instance) {
+ onUnmounted(off)
}
}
@@ -166,6 +169,14 @@ export function useLazyAsyncData<
return useAsyncData(key, handler, { ...options, lazy: true })
}
+export function refreshNuxtData (keys?: string | string[]): Promise {
+ if (process.server) {
+ return Promise.resolve()
+ }
+ const _keys = keys ? Array.isArray(keys) ? keys : [keys] : undefined
+ return useNuxtApp().callHook('app:data:refresh', _keys)
+}
+
function pick (obj: Record, keys: string[]) {
const newObj = {}
for (const key of keys) {
diff --git a/packages/nuxt3/src/app/composables/index.ts b/packages/nuxt3/src/app/composables/index.ts
index 9f47d42c530..03300f55334 100644
--- a/packages/nuxt3/src/app/composables/index.ts
+++ b/packages/nuxt3/src/app/composables/index.ts
@@ -1,5 +1,5 @@
export { defineNuxtComponent } from './component'
-export { useAsyncData, useLazyAsyncData } from './asyncData'
+export { useAsyncData, useLazyAsyncData, refreshNuxtData } from './asyncData'
export type { AsyncDataOptions, AsyncData } from './asyncData'
export { useHydration } from './hydrate'
export { useState } from './state'
diff --git a/packages/nuxt3/src/app/nuxt.ts b/packages/nuxt3/src/app/nuxt.ts
index d3af122c2cd..56b909b53b9 100644
--- a/packages/nuxt3/src/app/nuxt.ts
+++ b/packages/nuxt3/src/app/nuxt.ts
@@ -23,6 +23,7 @@ export interface RuntimeNuxtHooks {
'app:suspense:resolve': (Component?: VNode) => HookResult
'app:error': (err: any) => HookResult
'app:error:cleared': (options: { redirect?: string }) => HookResult
+ 'app:data:refresh': (keys?: string[]) => HookResult
'page:start': (Component?: VNode) => HookResult
'page:finish': (Component?: VNode) => HookResult
'meta:register': (metaRenderers: Array<(nuxt: NuxtApp) => NuxtMeta | Promise>) => HookResult
diff --git a/packages/nuxt3/src/auto-imports/presets.ts b/packages/nuxt3/src/auto-imports/presets.ts
index 8c5c7bb53a1..62e4a76af2e 100644
--- a/packages/nuxt3/src/auto-imports/presets.ts
+++ b/packages/nuxt3/src/auto-imports/presets.ts
@@ -23,6 +23,7 @@ export const appPreset = defineUnimportPreset({
imports: [
'useAsyncData',
'useLazyAsyncData',
+ 'refreshNuxtData',
'defineNuxtComponent',
'useNuxtApp',
'defineNuxtPlugin',
From d3a1ed983958b0ab254396eda0cdb3c37ae33a7c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Chopin?=
Date: Tue, 29 Mar 2022 15:14:11 +0200
Subject: [PATCH 04/45] docs(cli): fix typo (exsits -> exists) (#3954)
---
docs/content/3.docs/1.usage/8.cli.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/content/3.docs/1.usage/8.cli.md b/docs/content/3.docs/1.usage/8.cli.md
index 9db5ad83d30..4d412b5bdd2 100644
--- a/docs/content/3.docs/1.usage/8.cli.md
+++ b/docs/content/3.docs/1.usage/8.cli.md
@@ -114,7 +114,7 @@ Option | Default | Description
`TEMPLATE` | - | Specify a template of the file to be generated.
`NAME` | - | Specify a name of the file that will be created.
`--cwd` | `.` | The directory of the target application.
-`--force` | `false` | Force override file if already exsits.
+`--force` | `false` | Force override file if it already exists.
**Example:**
From c28c6a8c8abf603315bcef9e5e6af4982a3399c8 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Tue, 29 Mar 2022 15:23:36 +0200
Subject: [PATCH 05/45] chore(deps): update all non-major dependencies (#3952)
Co-authored-by: Renovate Bot
---
package.json | 6 ++---
packages/test-utils/package.json | 2 +-
packages/vite/package.json | 2 +-
yarn.lock | 46 ++++++++++++++++----------------
4 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/package.json b/package.json
index 702146c551f..a40ae3cc506 100644
--- a/package.json
+++ b/package.json
@@ -41,10 +41,10 @@
"@types/jsdom": "^16",
"@types/node": "^16.11.26",
"@types/object-hash": "^2",
- "@unocss/reset": "^0.30.6",
+ "@unocss/reset": "^0.30.7",
"esbuild": "^0.14.28",
"eslint": "^8.12.0",
- "eslint-plugin-jsdoc": "^38.1.3",
+ "eslint-plugin-jsdoc": "^38.1.4",
"execa": "^6.1.0",
"expect-type": "^0.13.0",
"globby": "^13.1.1",
@@ -56,7 +56,7 @@
"pathe": "^0.2.0",
"typescript": "^4.6.3",
"unbuild": "^0.7.2",
- "vitest": "^0.7.12",
+ "vitest": "^0.8.0",
"vue-router": "^4.0.14",
"vue-tsc": "^0.33.9"
},
diff --git a/packages/test-utils/package.json b/packages/test-utils/package.json
index dce49998255..80820d80e91 100644
--- a/packages/test-utils/package.json
+++ b/packages/test-utils/package.json
@@ -24,7 +24,7 @@
"devDependencies": {
"playwright": "^1.20.1",
"unbuild": "latest",
- "vitest": "^0.7.12"
+ "vitest": "^0.8.0"
},
"peerDependencies": {
"vue": "3.2.31"
diff --git a/packages/vite/package.json b/packages/vite/package.json
index 8cfb7315248..40a2ebabbb8 100644
--- a/packages/vite/package.json
+++ b/packages/vite/package.json
@@ -44,7 +44,7 @@
"ufo": "^0.8.1",
"unplugin": "^0.6.0",
"vite": "^2.8.6",
- "vite-node": "^0.7.12"
+ "vite-node": "^0.8.0"
},
"peerDependencies": {
"vue": "3.2.31"
diff --git a/yarn.lock b/yarn.lock
index cdebade2dd9..622e620557c 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3209,7 +3209,7 @@ __metadata:
ohmyfetch: ^0.4.15
playwright: ^1.20.1
unbuild: latest
- vitest: ^0.7.12
+ vitest: ^0.8.0
peerDependencies:
vue: 3.2.31
languageName: unknown
@@ -3342,7 +3342,7 @@ __metadata:
unbuild: latest
unplugin: ^0.6.0
vite: ^2.8.6
- vite-node: ^0.7.12
+ vite-node: ^0.8.0
vue: 3.2.31
peerDependencies:
vue: 3.2.31
@@ -4956,10 +4956,10 @@ __metadata:
languageName: node
linkType: hard
-"@unocss/reset@npm:^0.30.6":
- version: 0.30.6
- resolution: "@unocss/reset@npm:0.30.6"
- checksum: 828864eeff7340976f4feecb3efbfe9cd8cf7d8ef9a85b81d62add1b4644d6638c586aa07f7d35ea46d0fc6d5aaf6b41b04733acc873c9d9fbbea8fee0048725
+"@unocss/reset@npm:^0.30.7":
+ version: 0.30.7
+ resolution: "@unocss/reset@npm:0.30.7"
+ checksum: ccdf559fd0270dcf77483746f89b9e94b97f7717c323ab7ff339e2137e6a9436aaf4d577732fb58168d497240f121cb02785ad9f43b93d9caa9c208ad7f78395
languageName: node
linkType: hard
@@ -10324,9 +10324,9 @@ __metadata:
languageName: node
linkType: hard
-"eslint-plugin-jsdoc@npm:^38.1.3":
- version: 38.1.3
- resolution: "eslint-plugin-jsdoc@npm:38.1.3"
+"eslint-plugin-jsdoc@npm:^38.1.4":
+ version: 38.1.4
+ resolution: "eslint-plugin-jsdoc@npm:38.1.4"
dependencies:
"@es-joy/jsdoccomment": ~0.22.1
comment-parser: 1.3.1
@@ -10338,7 +10338,7 @@ __metadata:
spdx-expression-parse: ^3.0.1
peerDependencies:
eslint: ^7.0.0 || ^8.0.0
- checksum: 4b9523423c6c5fbbe378997e2deaa651bbfa9badca6e9f2785c69f4e5de05fecf32ca3557efd4f9f14f8bc0708ff6fd9aacdd91c5dac88f5768dd05d269d6045
+ checksum: 24cf53cfa2282a967f5af25a8feed02b6faa19a818b9c3cfe6ba615b499e2940bf1004fc1c06e1b44f8370ed61c65d90acc44ef26032c09804d6484eb1e8cfd7
languageName: node
linkType: hard
@@ -15652,10 +15652,10 @@ __metadata:
"@types/jsdom": ^16
"@types/node": ^16.11.26
"@types/object-hash": ^2
- "@unocss/reset": ^0.30.6
+ "@unocss/reset": ^0.30.7
esbuild: ^0.14.28
eslint: ^8.12.0
- eslint-plugin-jsdoc: ^38.1.3
+ eslint-plugin-jsdoc: ^38.1.4
execa: ^6.1.0
expect-type: ^0.13.0
globby: ^13.1.1
@@ -15667,7 +15667,7 @@ __metadata:
pathe: ^0.2.0
typescript: ^4.6.3
unbuild: ^0.7.2
- vitest: ^0.7.12
+ vitest: ^0.8.0
vue-router: ^4.0.14
vue-tsc: ^0.33.9
languageName: unknown
@@ -21866,18 +21866,18 @@ __metadata:
languageName: node
linkType: hard
-"vite-node@npm:^0.7.12":
- version: 0.7.12
- resolution: "vite-node@npm:0.7.12"
+"vite-node@npm:^0.8.0":
+ version: 0.8.0
+ resolution: "vite-node@npm:0.8.0"
dependencies:
kolorist: ^1.5.1
- minimist: ^1.2.5
- mlly: ^0.4.3
+ minimist: ^1.2.6
+ mlly: ^0.5.1
pathe: ^0.2.0
vite: ^2.8.6
bin:
vite-node: vite-node.mjs
- checksum: fae00ca889e053e6ce95313c8aeb3b3bbfc792148d618f68a2069dc67b36ef379ad547e94de29b6a4ca92f6325cffabe38fe6d599aefcb9410f36bc06665a57c
+ checksum: d6275d264892f695b40257be9f968ba7a3c58334b5ec62f19b3a58e718cbbb7d6be1aed5fe738b09779aa64c571ce4b9aa78e5878b5baa3d3eeff27a6378f877
languageName: node
linkType: hard
@@ -21941,9 +21941,9 @@ __metadata:
languageName: node
linkType: hard
-"vitest@npm:^0.7.12":
- version: 0.7.12
- resolution: "vitest@npm:0.7.12"
+"vitest@npm:^0.8.0":
+ version: 0.8.0
+ resolution: "vitest@npm:0.8.0"
dependencies:
"@types/chai": ^4.3.0
"@types/chai-subset": ^1.3.3
@@ -21968,7 +21968,7 @@ __metadata:
optional: true
bin:
vitest: vitest.mjs
- checksum: 62ed3078336e0b6cd093fe8d7f7ef2eb8f97996732e8aa78b1d2d495539e23a1e905253aeb515956b56b1c92cfe9346537416a90c4b0e7061fc6b944eec2ae61
+ checksum: efc6e998f79377804bfed7354eac1dfd73add7be1be249b86bff698bf4535eb69a79eed47e958e9a5fa29d07a8eac47b0cd0e22d87eb88571163e0d97000b069
languageName: node
linkType: hard
From 7e6c4e2d5bbb27f0fda38b4c6f1b0462e8d83416 Mon Sep 17 00:00:00 2001
From: pooya parsa
Date: Wed, 30 Mar 2022 10:17:46 +0200
Subject: [PATCH 06/45] fix(schema): fix RouterConfig types (#3964)
---
docs/content/3.docs/2.directory-structure/10.pages.md | 4 ++--
packages/schema/src/config/router.ts | 2 +-
packages/schema/src/types/router.ts | 11 +++++++++--
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/docs/content/3.docs/2.directory-structure/10.pages.md b/docs/content/3.docs/2.directory-structure/10.pages.md
index e5395764a96..7baa9738071 100644
--- a/docs/content/3.docs/2.directory-structure/10.pages.md
+++ b/docs/content/3.docs/2.directory-structure/10.pages.md
@@ -274,10 +274,10 @@ It is possible to set default [vue-router options](https://router.vuejs.org/api/
This is the recommaned way to specify router options.
```js [app/router.options.ts]
-import type { RouterOptions } from '@nuxt/schema'
+import type { RouterConfig } from '@nuxt/schema'
// https://router.vuejs.org/api/#routeroptions
-export default {
+export default {
}
```
diff --git a/packages/schema/src/config/router.ts b/packages/schema/src/config/router.ts
index e8dae2aa3d6..3b5176de934 100644
--- a/packages/schema/src/config/router.ts
+++ b/packages/schema/src/config/router.ts
@@ -9,7 +9,7 @@ export default {
* For more control, you can use `app/router.optionts.ts` file.
*
* @see [documentation](https://router.vuejs.org/api/#routeroptions)
- * @type {import('../src/types/router').RouterConfigOptions}
+ * @type {import('../src/types/router').RouterConfigSerializable}
*
* @version 3
*/
diff --git a/packages/schema/src/types/router.ts b/packages/schema/src/types/router.ts
index a5cb900c0c4..03e0fabdc8b 100644
--- a/packages/schema/src/types/router.ts
+++ b/packages/schema/src/types/router.ts
@@ -1,9 +1,16 @@
import type { RouterOptions as _RouterOptions } from 'vue-router'
-export type RouterOptions = Exclude<_RouterOptions, 'history' | 'routes'>
+export type RouterConfig = Partial>
+
+/** @deprecated Use RouterConfig instead */
+export type RouterOptions = RouterConfig
/**
* Only JSON serializable router options are configurable from nuxt config
*/
-export type RouterConfigOptions = Pick
+export type RouterConfigSerializable = Pick
+
+
+/** @deprecated Use RouterConfigSerializable instead */
+export type RouterConfigOptions = RouterConfigSerializable
From 91817349124c0280189c441e1a97a476953d18e0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Ollivier?=
Date: Wed, 30 Mar 2022 10:34:05 +0200
Subject: [PATCH 07/45] docs(examples): fix minor errors (#3965)
---
examples/with-reactivity-transform/app.vue | 2 --
examples/with-reactivity-transform/{ => components}/label.vue | 0
examples/with-wasm/package.json | 1 +
yarn.lock | 1 +
4 files changed, 2 insertions(+), 2 deletions(-)
rename examples/with-reactivity-transform/{ => components}/label.vue (100%)
diff --git a/examples/with-reactivity-transform/app.vue b/examples/with-reactivity-transform/app.vue
index ef0e09d94c1..c938a885223 100644
--- a/examples/with-reactivity-transform/app.vue
+++ b/examples/with-reactivity-transform/app.vue
@@ -1,6 +1,4 @@
+
+
diff --git a/docs/components/templates/Example.vue b/docs/components/templates/Example.vue
new file mode 100644
index 00000000000..a09688a513b
--- /dev/null
+++ b/docs/components/templates/Example.vue
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/content/4.examples/0.essentials/hello-world.md b/docs/content/4.examples/0.essentials/hello-world.md
new file mode 100644
index 00000000000..243c63daf23
--- /dev/null
+++ b/docs/content/4.examples/0.essentials/hello-world.md
@@ -0,0 +1,13 @@
+---
+template: Example
+---
+
+# Hello world
+
+A minimal Nuxt 3 application only requires the `app.vue` and `nuxt.config.js` files.
+
+::alert{type=info icon=👉}
+Read more about [installation](/getting-started/installation).
+::
+
+::sandbox{repo="nuxt/framework" branch="main" dir="examples/essentials/hello-world" file="app.vue"}
diff --git a/docs/content/4.examples/1.app/error-handling.md b/docs/content/4.examples/1.app/error-handling.md
new file mode 100644
index 00000000000..83982209455
--- /dev/null
+++ b/docs/content/4.examples/1.app/error-handling.md
@@ -0,0 +1,13 @@
+---
+template: Example
+---
+
+# Error Handling
+
+This example shows how to handle errors in different contexts: pages, plugins, components and middleware.
+
+::alert{type=info icon=👉}
+Learn more about [error handling](/docs/usage/error-handling).
+::
+
+::sandbox{repo="nuxt/framework" branch="main" dir="examples/app/errors" file="app.vue"}
diff --git a/docs/content/4.examples/1.app/plugins.md b/docs/content/4.examples/1.app/plugins.md
new file mode 100644
index 00000000000..93fa2e938f2
--- /dev/null
+++ b/docs/content/4.examples/1.app/plugins.md
@@ -0,0 +1,13 @@
+---
+template: Example
+---
+
+# Plugins
+
+This example shows how to use the `plugins/` directory to auto-register plugins.
+
+::alert{type=info icon=👉}
+Learn more about [plugins](/docs/directory-structure/plugins).
+::
+
+::sandbox{repo="nuxt/framework" branch="main" dir="examples/app/plugins" file="app.vue"}
diff --git a/docs/content/4.examples/2.auto-imports/components.md b/docs/content/4.examples/2.auto-imports/components.md
new file mode 100644
index 00000000000..43d7c9e8115
--- /dev/null
+++ b/docs/content/4.examples/2.auto-imports/components.md
@@ -0,0 +1,14 @@
+---
+template: Example
+---
+
+# Components
+
+Components in the `components/` directory are auto imported and can be directly used in your templates.
+You can configure other directories to support components auto-imports.
+
+::alert{type=info icon=👉}
+Read more about [the components directory](/docs/directory-structure/components).
+::
+
+::sandbox{repo="nuxt/framework" branch="main" dir="examples/auto-imports/components" file="app.vue"}
diff --git a/docs/content/4.examples/2.auto-imports/composables.md b/docs/content/4.examples/2.auto-imports/composables.md
new file mode 100644
index 00000000000..7dfa050ecf0
--- /dev/null
+++ b/docs/content/4.examples/2.auto-imports/composables.md
@@ -0,0 +1,14 @@
+---
+template: Example
+---
+
+# Composables
+
+This example shows how to use the `composables/` directory to auto import composables.
+If the component file provides a default export, the name of the composable will be mapped to the name of the file. Named exports can be used as-is.
+
+::alert{type=info icon=👉}
+Read more about [the composables directory](/docs/directory-structure/composables).
+::
+
+::sandbox{repo="nuxt/framework" branch="main" dir="examples/auto-imports/composables" file="app.vue"}
diff --git a/docs/content/4.examples/3.composables/use-async-data.md b/docs/content/4.examples/3.composables/use-async-data.md
new file mode 100644
index 00000000000..e5fe6becfa3
--- /dev/null
+++ b/docs/content/4.examples/3.composables/use-async-data.md
@@ -0,0 +1,17 @@
+---
+template: Example
+---
+
+# useAsyncData
+
+This example shows how to use `useAsyncData` to fetch data from an API endpoint.
+
+::alert{type=info icon=💡}
+Nuxt will automatically read files in the ~/server/api directory to create API endpoints.
+::
+
+::alert{type=info icon=👉}
+Learn more about [data fetching](/docs/usage/data-fetching).
+::
+
+::sandbox{repo="nuxt/framework" branch="main" dir="examples/composables/use-async-data" file="app.vue"}
diff --git a/docs/content/4.examples/3.composables/use-cookie.md b/docs/content/4.examples/3.composables/use-cookie.md
new file mode 100644
index 00000000000..bd71e424218
--- /dev/null
+++ b/docs/content/4.examples/3.composables/use-cookie.md
@@ -0,0 +1,13 @@
+---
+template: Example
+---
+
+# useCookie
+
+This example shows how to use the `useCookie` API to persist small amounts of data that both client-side and server-side can use.
+
+::alert{type=info icon=👉}
+Learn more about [useCookie](/docs/usage/cookies).
+::
+
+::sandbox{repo="nuxt/framework" branch="main" dir="examples/composables/use-cookie" file="app.vue"}
diff --git a/docs/content/4.examples/3.composables/use-fetch.md b/docs/content/4.examples/3.composables/use-fetch.md
new file mode 100644
index 00000000000..05ab182db90
--- /dev/null
+++ b/docs/content/4.examples/3.composables/use-fetch.md
@@ -0,0 +1,17 @@
+---
+template: Example
+---
+
+# useFetch
+
+This example shows how to use `useFetch` to fetch data from an API endpoint.
+
+::alert{type=info icon=💡}
+Nuxt will automatically read files in the ~/server/api directory to create API endpoints.
+::
+
+::alert{type=info icon=👉}
+Learn more about [data fetching](/docs/usage/data-fetching).
+::
+
+::sandbox{repo="nuxt/framework" branch="main" dir="examples/composables/use-fetch" file="app.vue"}
diff --git a/docs/content/4.examples/3.composables/use-meta.md b/docs/content/4.examples/3.composables/use-meta.md
new file mode 100644
index 00000000000..b910efab732
--- /dev/null
+++ b/docs/content/4.examples/3.composables/use-meta.md
@@ -0,0 +1,13 @@
+---
+template: Example
+---
+
+# useMeta
+
+This example shows how to use `useMeta` and Nuxt built-in components to bind meta data to the head of the page.
+
+::alert{type=info icon=👉}
+Learn more about [meta tags](/docs/usage/meta-tags).
+::
+
+::sandbox{repo="nuxt/framework" branch="main" dir="examples/composables/use-meta" file="app.vue"}
diff --git a/docs/content/4.examples/3.composables/use-state.md b/docs/content/4.examples/3.composables/use-state.md
new file mode 100644
index 00000000000..524a2fe73a1
--- /dev/null
+++ b/docs/content/4.examples/3.composables/use-state.md
@@ -0,0 +1,13 @@
+---
+template: Example
+---
+
+# useState
+
+`useState` is an SSR-friendly ref replacement. Its value will be preserved after server-side rendering and shared across all components using a unique key.
+
+::alert{type=info icon=👉}
+Learn more about [useState](/docs/usage/state).
+::
+
+::sandbox{repo="nuxt/framework" branch="main" dir="examples/composables/use-state" file="app.vue"}
diff --git a/docs/content/4.examples/4.routing/layouts.md b/docs/content/4.examples/4.routing/layouts.md
new file mode 100644
index 00000000000..309aba9486d
--- /dev/null
+++ b/docs/content/4.examples/4.routing/layouts.md
@@ -0,0 +1,13 @@
+---
+template: Example
+---
+
+# Layouts
+
+This example shows how to define default and custom layouts.
+
+::alert{type=info icon=👉}
+Learn more about [layouts](/docs/directory-structure/layouts).
+::
+
+::sandbox{repo="nuxt/framework" branch="main" dir="examples/routing/layouts" file="pages/index.vue"}
diff --git a/docs/content/4.examples/4.routing/middleware.md b/docs/content/4.examples/4.routing/middleware.md
new file mode 100644
index 00000000000..a867f19c671
--- /dev/null
+++ b/docs/content/4.examples/4.routing/middleware.md
@@ -0,0 +1,13 @@
+---
+template: Example
+---
+
+# Middleware
+
+This example shows how to add route middleware with the middleware/ directory or with a plugin, and how to use them globally or per page.
+
+::alert{type=info icon=👉}
+Learn more about [middleware](/docs/directory-structure/middleware).
+::
+
+::sandbox{repo="nuxt/framework" branch="main" dir="examples/routing/middleware" file="app.vue"}
diff --git a/docs/content/4.examples/4.routing/nuxt-link.md b/docs/content/4.examples/4.routing/nuxt-link.md
new file mode 100644
index 00000000000..8be8cd7ae53
--- /dev/null
+++ b/docs/content/4.examples/4.routing/nuxt-link.md
@@ -0,0 +1,17 @@
+---
+template: Example
+---
+
+# NuxtLink
+
+This example shows different ways to use Nuxtlink.
+
+::alert{type=info icon=💡}
+`components/myNuxtLink.js` defines a custom NuxtLink.
+::
+
+::alert{type=info icon=👉}
+Learn more about [NuxtLink](/docs/usage/nuxt-link).
+::
+
+::sandbox{repo="nuxt/framework" branch="main" dir="examples/routing/nuxt-link" file="app.vue"}
diff --git a/docs/content/4.examples/4.routing/pages.md b/docs/content/4.examples/4.routing/pages.md
new file mode 100644
index 00000000000..96d3f63d893
--- /dev/null
+++ b/docs/content/4.examples/4.routing/pages.md
@@ -0,0 +1,13 @@
+---
+template: Example
+---
+
+# Pages
+
+This example shows how to use the `pages/` directory to create application routes.
+
+::alert{type=info icon=👉}
+Learn more about [pages](/docs/directory-structure/pages).
+::
+
+::sandbox{repo="nuxt/framework" branch="main" dir="examples/routing/pages" file="app.vue"}
diff --git a/docs/content/4.examples/4.routing/universal-router.md b/docs/content/4.examples/4.routing/universal-router.md
new file mode 100644
index 00000000000..f52df483701
--- /dev/null
+++ b/docs/content/4.examples/4.routing/universal-router.md
@@ -0,0 +1,9 @@
+---
+template: Example
+---
+
+# Universal Router
+
+This example demonstrates Nuxt universal routing utilities without depending on `pages/` and `vue-router`.
+
+::sandbox{repo="nuxt/framework" branch="main" dir="examples/routing/universal-router" file="app.vue"}
diff --git a/docs/content/4.examples/5.advanced/config-extends.md b/docs/content/4.examples/5.advanced/config-extends.md
new file mode 100644
index 00000000000..44e12bdfb73
--- /dev/null
+++ b/docs/content/4.examples/5.advanced/config-extends.md
@@ -0,0 +1,9 @@
+---
+template: Example
+---
+
+# Config extends
+
+This example shows how to use the `extends` key in nuxt.config.ts to use the base/ directory as a base Nuxt application, and use its components, composables or config and override them if necessary.
+
+::sandbox{repo="nuxt/framework" branch="main" dir="examples/advanced/config-extends" file="nuxt.config.ts"}
diff --git a/docs/content/4.examples/5.advanced/module-extend-pages.md b/docs/content/4.examples/5.advanced/module-extend-pages.md
new file mode 100644
index 00000000000..c34fd92af3c
--- /dev/null
+++ b/docs/content/4.examples/5.advanced/module-extend-pages.md
@@ -0,0 +1,13 @@
+---
+template: Example
+---
+
+# Module Extend pages
+
+This example defines a new `test` page using `extendPages` within a module.
+
+::alert{type=info icon=👉}
+Learn more about [modules creation](/docs/advanced/modules).
+::
+
+::sandbox{repo="nuxt/framework" branch="main" dir="examples/advanced/module-extend-pages" file="pages/index.vue"}
diff --git a/docs/content/4.examples/5.advanced/test.md b/docs/content/4.examples/5.advanced/test.md
new file mode 100644
index 00000000000..fdf30782073
--- /dev/null
+++ b/docs/content/4.examples/5.advanced/test.md
@@ -0,0 +1,7 @@
+---
+template: Example
+---
+
+# Test
+
+::sandbox{repo="nuxt/framework" branch="main" dir="examples/advanced/test" file="app.vue"}
diff --git a/docs/content/4.examples/6.experimental/reactivity-transform.md b/docs/content/4.examples/6.experimental/reactivity-transform.md
new file mode 100644
index 00000000000..888b6c4f871
--- /dev/null
+++ b/docs/content/4.examples/6.experimental/reactivity-transform.md
@@ -0,0 +1,13 @@
+---
+template: Example
+---
+
+# Reactivity Transform
+
+This example demonstrates the support of Reactivity transform in Nuxt 3.
+
+::alert{type=info icon=👉}
+Learn more about [Reactivity transform](https://vuejs.org/guide/extras/reactivity-transform.html) on the Vue docs.
+::
+
+::sandbox{repo="nuxt/framework" branch="main" dir="examples/experimental/reactivity-transform" file="app.vue"}
diff --git a/docs/content/4.examples/6.experimental/wasm.md b/docs/content/4.examples/6.experimental/wasm.md
new file mode 100644
index 00000000000..6dd502905a5
--- /dev/null
+++ b/docs/content/4.examples/6.experimental/wasm.md
@@ -0,0 +1,9 @@
+---
+template: Example
+---
+
+# Wasm
+
+This example demonstrates the server-side support of WebAssembly in Nuxt 3.
+
+::sandbox{repo="nuxt/framework" branch="main" dir="examples/experimental/wasm" file="app.vue"}
diff --git a/docs/content/4.examples/7.other/locale.md b/docs/content/4.examples/7.other/locale.md
new file mode 100644
index 00000000000..01c37c2dce6
--- /dev/null
+++ b/docs/content/4.examples/7.other/locale.md
@@ -0,0 +1,13 @@
+---
+template: Example
+---
+
+# Locale
+
+This example shows how to define a locale composable to handle the application's locale, both server and client-side.
+
+::alert{type=info icon=💡}
+You can right click to "View Page Source" and see that Nuxt renders the correct date in SSR based on visitor's locale.
+::
+
+::sandbox{repo="nuxt/framework" branch="main" dir="examples/other/locale" file="app.vue"}
diff --git a/docs/content/4.examples/index.md b/docs/content/4.examples/index.md
new file mode 100644
index 00000000000..acf6d0c78ac
--- /dev/null
+++ b/docs/content/4.examples/index.md
@@ -0,0 +1,9 @@
+---
+title: Examples
+layout.aside: true
+layout.fluid: true
+navigation:
+ exclusive: true
+ collapse: true
+ redirect: /examples/essentials/hello-world
+---
diff --git a/docs/content/4.community/1.getting-help.md b/docs/content/5.community/1.getting-help.md
similarity index 100%
rename from docs/content/4.community/1.getting-help.md
rename to docs/content/5.community/1.getting-help.md
diff --git a/docs/content/4.community/2.reporting-bugs.md b/docs/content/5.community/2.reporting-bugs.md
similarity index 100%
rename from docs/content/4.community/2.reporting-bugs.md
rename to docs/content/5.community/2.reporting-bugs.md
diff --git a/docs/content/4.community/3.contribution.md b/docs/content/5.community/3.contribution.md
similarity index 100%
rename from docs/content/4.community/3.contribution.md
rename to docs/content/5.community/3.contribution.md
diff --git a/docs/content/4.community/4.roadmap.md b/docs/content/5.community/4.roadmap.md
similarity index 100%
rename from docs/content/4.community/4.roadmap.md
rename to docs/content/5.community/4.roadmap.md
diff --git a/docs/content/4.community/index.md b/docs/content/5.community/index.md
similarity index 100%
rename from docs/content/4.community/index.md
rename to docs/content/5.community/index.md
diff --git a/docs/content/_collections/header.md b/docs/content/_collections/header.md
index ce34c8f6b10..69ad9598b0f 100644
--- a/docs/content/_collections/header.md
+++ b/docs/content/_collections/header.md
@@ -9,6 +9,9 @@ links:
-
title: 'Docs'
to: '/docs/usage/data-fetching'
+ -
+ title: 'Examples'
+ to: '/examples/essentials/hello-world'
-
title: 'Community'
to: '/community/getting-help'
diff --git a/examples/README.md b/examples/README.md
index cd0f41be6b6..025e64a94ea 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -10,10 +10,10 @@
| `use-fetch` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/use-fetch) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/use-fetch?file=app.vue&terminal=dev) |
| `use-meta` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/use-meta) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/use-meta?file=app.vue&terminal=dev) |
| `use-state` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/use-state) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/use-state?file=app.vue&terminal=dev) |
-| `with-components` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/with-components) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/with-components?file=app.vue&terminal=dev) |
-| `with-composables` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/with-composables) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/with-composables?file=app.vue&terminal=dev) |
-| `with-layouts` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/with-layouts) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/with-layouts?file=app.vue&terminal=dev) |
-| `with-pages` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/with-pages) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/with-pages?file=app.vue&terminal=dev) |
-| `with-plugins` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/with-plugins) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/with-plugins?file=app.vue&terminal=dev) |
-| `with-universal-router` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/with-universal-router) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/with-universal-router?file=app.vue&terminal=dev) |
-| `with-wasm` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/with-wasm) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/with-wasm?file=app.vue&terminal=dev) |
+| `components` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/components) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/components?file=app.vue&terminal=dev) |
+| `composables` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/composables) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/composables?file=app.vue&terminal=dev) |
+| `layouts` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/layouts) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/layouts?file=app.vue&terminal=dev) |
+| `pages` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/pages) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/pages?file=app.vue&terminal=dev) |
+| `plugins` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/plugins) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/plugins?file=app.vue&terminal=dev) |
+| `universal-router` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/universal-router) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/universal-router?file=app.vue&terminal=dev) |
+| `wasm` | [GitHub](https://github.com/nuxt/framework/tree/main/examples/wasm) | [Play Online](https://stackblitz.com/github/nuxt/framework/tree/main/examples/wasm?file=app.vue&terminal=dev) |
diff --git a/examples/config-extends/base/components/BaseButton.vue b/examples/advanced/config-extends/base/components/BaseButton.vue
similarity index 100%
rename from examples/config-extends/base/components/BaseButton.vue
rename to examples/advanced/config-extends/base/components/BaseButton.vue
diff --git a/examples/config-extends/base/components/FancyButton.vue b/examples/advanced/config-extends/base/components/FancyButton.vue
similarity index 100%
rename from examples/config-extends/base/components/FancyButton.vue
rename to examples/advanced/config-extends/base/components/FancyButton.vue
diff --git a/examples/config-extends/base/composables/foo.ts b/examples/advanced/config-extends/base/composables/foo.ts
similarity index 100%
rename from examples/config-extends/base/composables/foo.ts
rename to examples/advanced/config-extends/base/composables/foo.ts
diff --git a/examples/config-extends/base/middleware/foo.ts b/examples/advanced/config-extends/base/middleware/foo.ts
similarity index 100%
rename from examples/config-extends/base/middleware/foo.ts
rename to examples/advanced/config-extends/base/middleware/foo.ts
diff --git a/examples/config-extends/base/nuxt.config.ts b/examples/advanced/config-extends/base/nuxt.config.ts
similarity index 100%
rename from examples/config-extends/base/nuxt.config.ts
rename to examples/advanced/config-extends/base/nuxt.config.ts
diff --git a/examples/config-extends/base/pages/foo.vue b/examples/advanced/config-extends/base/pages/foo.vue
similarity index 100%
rename from examples/config-extends/base/pages/foo.vue
rename to examples/advanced/config-extends/base/pages/foo.vue
diff --git a/examples/config-extends/base/plugins/my-plugin.ts b/examples/advanced/config-extends/base/plugins/my-plugin.ts
similarity index 100%
rename from examples/config-extends/base/plugins/my-plugin.ts
rename to examples/advanced/config-extends/base/plugins/my-plugin.ts
diff --git a/examples/config-extends/base/server/api/base.ts b/examples/advanced/config-extends/base/server/api/base.ts
similarity index 100%
rename from examples/config-extends/base/server/api/base.ts
rename to examples/advanced/config-extends/base/server/api/base.ts
diff --git a/examples/config-extends/base/utils/bar.ts b/examples/advanced/config-extends/base/utils/bar.ts
similarity index 100%
rename from examples/config-extends/base/utils/bar.ts
rename to examples/advanced/config-extends/base/utils/bar.ts
diff --git a/examples/config-extends/components/FancyButton.vue b/examples/advanced/config-extends/components/FancyButton.vue
similarity index 100%
rename from examples/config-extends/components/FancyButton.vue
rename to examples/advanced/config-extends/components/FancyButton.vue
diff --git a/examples/config-extends/nuxt.config.ts b/examples/advanced/config-extends/nuxt.config.ts
similarity index 100%
rename from examples/config-extends/nuxt.config.ts
rename to examples/advanced/config-extends/nuxt.config.ts
diff --git a/examples/config-extends/package.json b/examples/advanced/config-extends/package.json
similarity index 100%
rename from examples/config-extends/package.json
rename to examples/advanced/config-extends/package.json
diff --git a/examples/config-extends/pages/index.vue b/examples/advanced/config-extends/pages/index.vue
similarity index 57%
rename from examples/config-extends/pages/index.vue
rename to examples/advanced/config-extends/pages/index.vue
index 75814a417ef..bea48768761 100644
--- a/examples/config-extends/pages/index.vue
+++ b/examples/advanced/config-extends/pages/index.vue
@@ -5,7 +5,7 @@ const bar = getBar()
-
+
theme runtimeConfig
{{ JSON.stringify(themeConfig, null, 2) }}
Base Button
@@ -15,11 +15,6 @@ const bar = getBar()
{{ foo }} {{ bar }}
{{ $myPlugin() }}
-
-
- This example shows how to use the extends key in nuxt.config.ts to use the base/ directory as a base Nuxt application, and use its components, composable or config and override them if necessary.
-
-
diff --git a/examples/config-extends/server/api/hello.ts b/examples/advanced/config-extends/server/api/hello.ts
similarity index 100%
rename from examples/config-extends/server/api/hello.ts
rename to examples/advanced/config-extends/server/api/hello.ts
diff --git a/examples/config-extends/tsconfig.json b/examples/advanced/config-extends/tsconfig.json
similarity index 100%
rename from examples/config-extends/tsconfig.json
rename to examples/advanced/config-extends/tsconfig.json
diff --git a/examples/config-extends/ui/components/Button.vue b/examples/advanced/config-extends/ui/components/Button.vue
similarity index 100%
rename from examples/config-extends/ui/components/Button.vue
rename to examples/advanced/config-extends/ui/components/Button.vue
diff --git a/examples/config-extends/ui/nuxt.config.ts b/examples/advanced/config-extends/ui/nuxt.config.ts
similarity index 100%
rename from examples/config-extends/ui/nuxt.config.ts
rename to examples/advanced/config-extends/ui/nuxt.config.ts
diff --git a/examples/advanced/module-extend-pages/layouts/default.vue b/examples/advanced/module-extend-pages/layouts/default.vue
new file mode 100644
index 00000000000..fec82618c2f
--- /dev/null
+++ b/examples/advanced/module-extend-pages/layouts/default.vue
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/examples/module-extend-pages/modules/pages/index.ts b/examples/advanced/module-extend-pages/modules/pages/index.ts
similarity index 100%
rename from examples/module-extend-pages/modules/pages/index.ts
rename to examples/advanced/module-extend-pages/modules/pages/index.ts
diff --git a/examples/module-extend-pages/modules/pages/pages/test.vue b/examples/advanced/module-extend-pages/modules/pages/pages/test.vue
similarity index 100%
rename from examples/module-extend-pages/modules/pages/pages/test.vue
rename to examples/advanced/module-extend-pages/modules/pages/pages/test.vue
diff --git a/examples/module-extend-pages/nuxt.config.ts b/examples/advanced/module-extend-pages/nuxt.config.ts
similarity index 100%
rename from examples/module-extend-pages/nuxt.config.ts
rename to examples/advanced/module-extend-pages/nuxt.config.ts
diff --git a/examples/module-extend-pages/package.json b/examples/advanced/module-extend-pages/package.json
similarity index 100%
rename from examples/module-extend-pages/package.json
rename to examples/advanced/module-extend-pages/package.json
diff --git a/examples/module-extend-pages/pages/index.vue b/examples/advanced/module-extend-pages/pages/index.vue
similarity index 100%
rename from examples/module-extend-pages/pages/index.vue
rename to examples/advanced/module-extend-pages/pages/index.vue
diff --git a/examples/hello-world/tsconfig.json b/examples/advanced/module-extend-pages/tsconfig.json
similarity index 100%
rename from examples/hello-world/tsconfig.json
rename to examples/advanced/module-extend-pages/tsconfig.json
diff --git a/examples/with-test/app.vue b/examples/advanced/test/app.vue
similarity index 100%
rename from examples/with-test/app.vue
rename to examples/advanced/test/app.vue
diff --git a/examples/hello-world/nuxt.config.ts b/examples/advanced/test/nuxt.config.ts
similarity index 100%
rename from examples/hello-world/nuxt.config.ts
rename to examples/advanced/test/nuxt.config.ts
diff --git a/examples/with-test/package.json b/examples/advanced/test/package.json
similarity index 84%
rename from examples/with-test/package.json
rename to examples/advanced/test/package.json
index cb24fd93641..50a91c5b67f 100644
--- a/examples/with-test/package.json
+++ b/examples/advanced/test/package.json
@@ -1,5 +1,5 @@
{
- "name": "example-with-test",
+ "name": "example-test",
"private": true,
"scripts": {
"build": "nuxi build",
diff --git a/examples/with-test/tests/basic.test.ts b/examples/advanced/test/tests/basic.test.ts
similarity index 100%
rename from examples/with-test/tests/basic.test.ts
rename to examples/advanced/test/tests/basic.test.ts
diff --git a/examples/locale/tsconfig.json b/examples/advanced/test/tsconfig.json
similarity index 100%
rename from examples/locale/tsconfig.json
rename to examples/advanced/test/tsconfig.json
diff --git a/examples/with-errors/app.vue b/examples/app/error-handling/app.vue
similarity index 76%
rename from examples/with-errors/app.vue
rename to examples/app/error-handling/app.vue
index c1b3b30102e..37059cb4e33 100644
--- a/examples/with-errors/app.vue
+++ b/examples/app/error-handling/app.vue
@@ -15,7 +15,7 @@ function triggerError () {
-
+
-
-
-
This example shows how to handle errors in different contexts: pages, plugins, components and middleware.
- This demo showcases using the
-
- useCookie
-
- API to persist small amounts of data that can be used both client-side and server-side.
-
-
diff --git a/examples/use-fetch/nuxt.config.ts b/examples/composables/use-cookie/nuxt.config.ts
similarity index 100%
rename from examples/use-fetch/nuxt.config.ts
rename to examples/composables/use-cookie/nuxt.config.ts
diff --git a/examples/use-cookie/package.json b/examples/composables/use-cookie/package.json
similarity index 100%
rename from examples/use-cookie/package.json
rename to examples/composables/use-cookie/package.json
diff --git a/examples/use-fetch/tsconfig.json b/examples/composables/use-cookie/tsconfig.json
similarity index 100%
rename from examples/use-fetch/tsconfig.json
rename to examples/composables/use-cookie/tsconfig.json
diff --git a/examples/composables/use-fetch/app.vue b/examples/composables/use-fetch/app.vue
new file mode 100644
index 00000000000..60645e1de16
--- /dev/null
+++ b/examples/composables/use-fetch/app.vue
@@ -0,0 +1,16 @@
+
+
+
+
+
+ Fetch result:
+
{{ data }}
+
+ +
+
+
+
+
diff --git a/examples/use-meta/nuxt.config.ts b/examples/composables/use-fetch/nuxt.config.ts
similarity index 100%
rename from examples/use-meta/nuxt.config.ts
rename to examples/composables/use-fetch/nuxt.config.ts
diff --git a/examples/use-fetch/package.json b/examples/composables/use-fetch/package.json
similarity index 100%
rename from examples/use-fetch/package.json
rename to examples/composables/use-fetch/package.json
diff --git a/examples/use-fetch/server/api/hello.ts b/examples/composables/use-fetch/server/api/hello.ts
similarity index 100%
rename from examples/use-fetch/server/api/hello.ts
rename to examples/composables/use-fetch/server/api/hello.ts
diff --git a/examples/use-meta/tsconfig.json b/examples/composables/use-fetch/tsconfig.json
similarity index 100%
rename from examples/use-meta/tsconfig.json
rename to examples/composables/use-fetch/tsconfig.json
diff --git a/examples/use-meta/app.vue b/examples/composables/use-meta/app.vue
similarity index 64%
rename from examples/use-meta/app.vue
rename to examples/composables/use-meta/app.vue
index 7590d28092c..210c0289b0e 100644
--- a/examples/use-meta/app.vue
+++ b/examples/composables/use-meta/app.vue
@@ -1,5 +1,5 @@
-
+
@@ -20,21 +20,6 @@
Click me and see the dynamic title
-
-
-
-
- This example shows how to use useMeta and Nuxt built-in components to bind meta data to the head of the page.
-
-
- Learn more about
-
- Meta tags
- .
- Open in editor to see the source code 👉
-
-
-
diff --git a/examples/use-state/nuxt.config.ts b/examples/composables/use-meta/nuxt.config.ts
similarity index 100%
rename from examples/use-state/nuxt.config.ts
rename to examples/composables/use-meta/nuxt.config.ts
diff --git a/examples/use-meta/package.json b/examples/composables/use-meta/package.json
similarity index 100%
rename from examples/use-meta/package.json
rename to examples/composables/use-meta/package.json
diff --git a/examples/with-components/tsconfig.json b/examples/composables/use-meta/tsconfig.json
similarity index 100%
rename from examples/with-components/tsconfig.json
rename to examples/composables/use-meta/tsconfig.json
diff --git a/examples/composables/use-state/app.vue b/examples/composables/use-state/app.vue
new file mode 100644
index 00000000000..450f6cf6e0f
--- /dev/null
+++ b/examples/composables/use-state/app.vue
@@ -0,0 +1,17 @@
+
+
+
+
+
Counter: {{ counter }}
+
+
+ +
+
+
+ -
+
+
+
+
diff --git a/examples/with-composables/nuxt.config.ts b/examples/composables/use-state/nuxt.config.ts
similarity index 100%
rename from examples/with-composables/nuxt.config.ts
rename to examples/composables/use-state/nuxt.config.ts
diff --git a/examples/use-state/package.json b/examples/composables/use-state/package.json
similarity index 100%
rename from examples/use-state/package.json
rename to examples/composables/use-state/package.json
diff --git a/examples/use-state/tsconfig.json b/examples/composables/use-state/tsconfig.json
similarity index 100%
rename from examples/use-state/tsconfig.json
rename to examples/composables/use-state/tsconfig.json
diff --git a/examples/hello-world/app.vue b/examples/essentials/hello-world/app.vue
similarity index 100%
rename from examples/hello-world/app.vue
rename to examples/essentials/hello-world/app.vue
diff --git a/examples/with-test/nuxt.config.ts b/examples/essentials/hello-world/nuxt.config.ts
similarity index 100%
rename from examples/with-test/nuxt.config.ts
rename to examples/essentials/hello-world/nuxt.config.ts
diff --git a/examples/hello-world/package.json b/examples/essentials/hello-world/package.json
similarity index 100%
rename from examples/hello-world/package.json
rename to examples/essentials/hello-world/package.json
diff --git a/examples/with-errors/tsconfig.json b/examples/essentials/hello-world/tsconfig.json
similarity index 100%
rename from examples/with-errors/tsconfig.json
rename to examples/essentials/hello-world/tsconfig.json
diff --git a/examples/experimental/reactivity-transform/app.vue b/examples/experimental/reactivity-transform/app.vue
new file mode 100644
index 00000000000..3a0e1001253
--- /dev/null
+++ b/examples/experimental/reactivity-transform/app.vue
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+ Inc
+
+
+ Dec
+
+
+
+
+
diff --git a/examples/with-reactivity-transform/components/label.vue b/examples/experimental/reactivity-transform/components/label.vue
similarity index 100%
rename from examples/with-reactivity-transform/components/label.vue
rename to examples/experimental/reactivity-transform/components/label.vue
diff --git a/examples/with-reactivity-transform/nuxt.config.ts b/examples/experimental/reactivity-transform/nuxt.config.ts
similarity index 100%
rename from examples/with-reactivity-transform/nuxt.config.ts
rename to examples/experimental/reactivity-transform/nuxt.config.ts
diff --git a/examples/with-composables/package.json b/examples/experimental/reactivity-transform/package.json
similarity index 83%
rename from examples/with-composables/package.json
rename to examples/experimental/reactivity-transform/package.json
index 666b5ab0e05..ea8e4cb6afc 100644
--- a/examples/with-composables/package.json
+++ b/examples/experimental/reactivity-transform/package.json
@@ -1,5 +1,5 @@
{
- "name": "example-with-composables",
+ "name": "example-reactivity-transform",
"private": true,
"scripts": {
"build": "nuxi build",
diff --git a/examples/with-layouts/tsconfig.json b/examples/experimental/reactivity-transform/tsconfig.json
similarity index 100%
rename from examples/with-layouts/tsconfig.json
rename to examples/experimental/reactivity-transform/tsconfig.json
diff --git a/examples/with-wasm/app.vue b/examples/experimental/wasm/app.vue
similarity index 69%
rename from examples/with-wasm/app.vue
rename to examples/experimental/wasm/app.vue
index 7320d8c66e6..cabccf8fca2 100644
--- a/examples/with-wasm/app.vue
+++ b/examples/experimental/wasm/app.vue
@@ -8,7 +8,7 @@ const { data } = await useAsyncData('sum',
-
+
a = 100
@@ -20,11 +20,5 @@ const { data } = await useAsyncData('sum',
{{ a }} + {{ b }} = {{ data.sum }}
-
-
-
- This example demonstrates the server-side support of WebAssembly in Nuxt 3.
-
-
diff --git a/examples/with-wasm/nuxt.config.ts b/examples/experimental/wasm/nuxt.config.ts
similarity index 100%
rename from examples/with-wasm/nuxt.config.ts
rename to examples/experimental/wasm/nuxt.config.ts
diff --git a/examples/with-layouts/package.json b/examples/experimental/wasm/package.json
similarity index 86%
rename from examples/with-layouts/package.json
rename to examples/experimental/wasm/package.json
index 4bd41fa5468..c398eb875b7 100644
--- a/examples/with-layouts/package.json
+++ b/examples/experimental/wasm/package.json
@@ -1,13 +1,13 @@
{
- "name": "example-with-layouts",
+ "name": "example-wasm",
"private": true,
- "scripts": {
- "build": "nuxi build",
- "dev": "nuxi dev",
- "start": "nuxi preview"
- },
"devDependencies": {
"@nuxt/ui": "npm:@nuxt/ui-edge@latest",
"nuxt3": "latest"
+ },
+ "scripts": {
+ "dev": "nuxi dev",
+ "build": "nuxi build",
+ "start": "nuxi preview"
}
}
diff --git a/examples/with-wasm/server/api/sum.ts b/examples/experimental/wasm/server/api/sum.ts
similarity index 100%
rename from examples/with-wasm/server/api/sum.ts
rename to examples/experimental/wasm/server/api/sum.ts
diff --git a/examples/with-wasm/server/wasm/sum.wasm b/examples/experimental/wasm/server/wasm/sum.wasm
similarity index 100%
rename from examples/with-wasm/server/wasm/sum.wasm
rename to examples/experimental/wasm/server/wasm/sum.wasm
diff --git a/examples/with-wasm/server/wasm/sum.wat b/examples/experimental/wasm/server/wasm/sum.wat
similarity index 100%
rename from examples/with-wasm/server/wasm/sum.wat
rename to examples/experimental/wasm/server/wasm/sum.wat
diff --git a/examples/with-middleware/tsconfig.json b/examples/experimental/wasm/tsconfig.json
similarity index 100%
rename from examples/with-middleware/tsconfig.json
rename to examples/experimental/wasm/tsconfig.json
diff --git a/examples/module-extend-pages/layouts/default.vue b/examples/module-extend-pages/layouts/default.vue
deleted file mode 100644
index fc8a25bd568..00000000000
--- a/examples/module-extend-pages/layouts/default.vue
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
- This example defines a new test page using extendPages within a module.
-
-
- useState
-
- is an SSR-friendly ref replacement.
- Its value will be preserved after server-side rendering
- and shared across all components using a unique key.
-
-
-
-
diff --git a/examples/with-reactivity-transform/package.json b/examples/with-reactivity-transform/package.json
deleted file mode 100644
index a38f3a0b004..00000000000
--- a/examples/with-reactivity-transform/package.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "name": "example-with-reactivity-transform",
- "private": true,
- "scripts": {
- "build": "nuxi build",
- "dev": "nuxi dev",
- "start": "nuxi preview"
- },
- "devDependencies": {
- "@nuxt/ui": "npm:@nuxt/ui-edge@latest",
- "nuxt3": "latest"
- }
-}
diff --git a/examples/with-universal-router/package.json b/examples/with-universal-router/package.json
deleted file mode 100644
index 3026a01a220..00000000000
--- a/examples/with-universal-router/package.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "name": "example-with-universal-router",
- "private": true,
- "scripts": {
- "build": "nuxi build",
- "dev": "nuxi dev",
- "start": "nuxi preview"
- },
- "devDependencies": {
- "@nuxt/ui": "npm:@nuxt/ui-edge@latest",
- "nuxt3": "latest"
- }
-}
diff --git a/package.json b/package.json
index 81ed1010d0b..175f1669c58 100644
--- a/package.json
+++ b/package.json
@@ -4,7 +4,7 @@
"type": "module",
"workspaces": [
"packages/*",
- "examples/*",
+ "examples/*/*",
"test/fixtures/*",
"playground"
],
diff --git a/yarn.lock b/yarn.lock
index 7ce75bca6c4..b8b7e8a962b 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -10424,187 +10424,187 @@ __metadata:
languageName: node
linkType: hard
-"example-config-extends@workspace:examples/config-extends":
+"example-components@workspace:examples/auto-imports/components":
version: 0.0.0-use.local
- resolution: "example-config-extends@workspace:examples/config-extends"
+ resolution: "example-components@workspace:examples/auto-imports/components"
dependencies:
"@nuxt/ui": "npm:@nuxt/ui-edge@latest"
nuxt3: latest
languageName: unknown
linkType: soft
-"example-hello-world@workspace:examples/hello-world":
+"example-composables@workspace:examples/auto-imports/composables":
version: 0.0.0-use.local
- resolution: "example-hello-world@workspace:examples/hello-world"
+ resolution: "example-composables@workspace:examples/auto-imports/composables"
dependencies:
+ "@nuxt/ui": "npm:@nuxt/ui-edge@latest"
nuxt3: latest
languageName: unknown
linkType: soft
-"example-locale@workspace:examples/locale":
+"example-config-extends@workspace:examples/advanced/config-extends":
version: 0.0.0-use.local
- resolution: "example-locale@workspace:examples/locale"
+ resolution: "example-config-extends@workspace:examples/advanced/config-extends"
dependencies:
"@nuxt/ui": "npm:@nuxt/ui-edge@latest"
nuxt3: latest
languageName: unknown
linkType: soft
-"example-module-extend-pages@workspace:examples/module-extend-pages":
+"example-error-handling@workspace:examples/app/error-handling":
version: 0.0.0-use.local
- resolution: "example-module-extend-pages@workspace:examples/module-extend-pages"
+ resolution: "example-error-handling@workspace:examples/app/error-handling"
dependencies:
"@nuxt/ui": "npm:@nuxt/ui-edge@latest"
nuxt3: latest
languageName: unknown
linkType: soft
-"example-nuxt-link@workspace:examples/nuxt-link":
+"example-hello-world@workspace:examples/essentials/hello-world":
version: 0.0.0-use.local
- resolution: "example-nuxt-link@workspace:examples/nuxt-link"
+ resolution: "example-hello-world@workspace:examples/essentials/hello-world"
dependencies:
- "@nuxt/ui": "npm:@nuxt/ui-edge@latest"
nuxt3: latest
languageName: unknown
linkType: soft
-"example-use-async-data@workspace:examples/use-async-data":
+"example-layouts@workspace:examples/routing/layouts":
version: 0.0.0-use.local
- resolution: "example-use-async-data@workspace:examples/use-async-data"
+ resolution: "example-layouts@workspace:examples/routing/layouts"
dependencies:
"@nuxt/ui": "npm:@nuxt/ui-edge@latest"
nuxt3: latest
languageName: unknown
linkType: soft
-"example-use-cookie@workspace:examples/use-cookie":
+"example-locale@workspace:examples/other/locale":
version: 0.0.0-use.local
- resolution: "example-use-cookie@workspace:examples/use-cookie"
+ resolution: "example-locale@workspace:examples/other/locale"
dependencies:
"@nuxt/ui": "npm:@nuxt/ui-edge@latest"
nuxt3: latest
languageName: unknown
linkType: soft
-"example-use-fetch@workspace:examples/use-fetch":
+"example-middleware@workspace:examples/routing/middleware":
version: 0.0.0-use.local
- resolution: "example-use-fetch@workspace:examples/use-fetch"
+ resolution: "example-middleware@workspace:examples/routing/middleware"
dependencies:
"@nuxt/ui": "npm:@nuxt/ui-edge@latest"
nuxt3: latest
languageName: unknown
linkType: soft
-"example-use-meta@workspace:examples/use-meta":
+"example-module-extend-pages@workspace:examples/advanced/module-extend-pages":
version: 0.0.0-use.local
- resolution: "example-use-meta@workspace:examples/use-meta"
+ resolution: "example-module-extend-pages@workspace:examples/advanced/module-extend-pages"
dependencies:
"@nuxt/ui": "npm:@nuxt/ui-edge@latest"
nuxt3: latest
languageName: unknown
linkType: soft
-"example-use-state@workspace:examples/use-state":
+"example-nuxt-link@workspace:examples/routing/nuxt-link":
version: 0.0.0-use.local
- resolution: "example-use-state@workspace:examples/use-state"
+ resolution: "example-nuxt-link@workspace:examples/routing/nuxt-link"
dependencies:
"@nuxt/ui": "npm:@nuxt/ui-edge@latest"
nuxt3: latest
languageName: unknown
linkType: soft
-"example-with-components@workspace:examples/with-components":
+"example-pages@workspace:examples/routing/pages":
version: 0.0.0-use.local
- resolution: "example-with-components@workspace:examples/with-components"
+ resolution: "example-pages@workspace:examples/routing/pages"
dependencies:
"@nuxt/ui": "npm:@nuxt/ui-edge@latest"
nuxt3: latest
languageName: unknown
linkType: soft
-"example-with-composables@workspace:examples/with-composables":
+"example-plugins@workspace:examples/app/plugins":
version: 0.0.0-use.local
- resolution: "example-with-composables@workspace:examples/with-composables"
+ resolution: "example-plugins@workspace:examples/app/plugins"
dependencies:
"@nuxt/ui": "npm:@nuxt/ui-edge@latest"
nuxt3: latest
languageName: unknown
linkType: soft
-"example-with-errors@workspace:examples/with-errors":
+"example-reactivity-transform@workspace:examples/experimental/reactivity-transform":
version: 0.0.0-use.local
- resolution: "example-with-errors@workspace:examples/with-errors"
+ resolution: "example-reactivity-transform@workspace:examples/experimental/reactivity-transform"
dependencies:
"@nuxt/ui": "npm:@nuxt/ui-edge@latest"
nuxt3: latest
languageName: unknown
linkType: soft
-"example-with-layouts@workspace:examples/with-layouts":
+"example-test@workspace:examples/advanced/test":
version: 0.0.0-use.local
- resolution: "example-with-layouts@workspace:examples/with-layouts"
+ resolution: "example-test@workspace:examples/advanced/test"
dependencies:
- "@nuxt/ui": "npm:@nuxt/ui-edge@latest"
nuxt3: latest
languageName: unknown
linkType: soft
-"example-with-middleware@workspace:examples/with-middleware":
+"example-universal-router@workspace:examples/routing/universal-router":
version: 0.0.0-use.local
- resolution: "example-with-middleware@workspace:examples/with-middleware"
+ resolution: "example-universal-router@workspace:examples/routing/universal-router"
dependencies:
"@nuxt/ui": "npm:@nuxt/ui-edge@latest"
nuxt3: latest
languageName: unknown
linkType: soft
-"example-with-pages@workspace:examples/with-pages":
+"example-use-async-data@workspace:examples/composables/use-async-data":
version: 0.0.0-use.local
- resolution: "example-with-pages@workspace:examples/with-pages"
+ resolution: "example-use-async-data@workspace:examples/composables/use-async-data"
dependencies:
"@nuxt/ui": "npm:@nuxt/ui-edge@latest"
nuxt3: latest
languageName: unknown
linkType: soft
-"example-with-plugins@workspace:examples/with-plugins":
+"example-use-cookie@workspace:examples/composables/use-cookie":
version: 0.0.0-use.local
- resolution: "example-with-plugins@workspace:examples/with-plugins"
+ resolution: "example-use-cookie@workspace:examples/composables/use-cookie"
dependencies:
"@nuxt/ui": "npm:@nuxt/ui-edge@latest"
nuxt3: latest
languageName: unknown
linkType: soft
-"example-with-reactivity-transform@workspace:examples/with-reactivity-transform":
+"example-use-fetch@workspace:examples/composables/use-fetch":
version: 0.0.0-use.local
- resolution: "example-with-reactivity-transform@workspace:examples/with-reactivity-transform"
+ resolution: "example-use-fetch@workspace:examples/composables/use-fetch"
dependencies:
"@nuxt/ui": "npm:@nuxt/ui-edge@latest"
nuxt3: latest
languageName: unknown
linkType: soft
-"example-with-test@workspace:examples/with-test":
+"example-use-meta@workspace:examples/composables/use-meta":
version: 0.0.0-use.local
- resolution: "example-with-test@workspace:examples/with-test"
+ resolution: "example-use-meta@workspace:examples/composables/use-meta"
dependencies:
+ "@nuxt/ui": "npm:@nuxt/ui-edge@latest"
nuxt3: latest
languageName: unknown
linkType: soft
-"example-with-universal-router@workspace:examples/with-universal-router":
+"example-use-state@workspace:examples/composables/use-state":
version: 0.0.0-use.local
- resolution: "example-with-universal-router@workspace:examples/with-universal-router"
+ resolution: "example-use-state@workspace:examples/composables/use-state"
dependencies:
"@nuxt/ui": "npm:@nuxt/ui-edge@latest"
nuxt3: latest
languageName: unknown
linkType: soft
-"example-with-wasm@workspace:examples/with-wasm":
+"example-wasm@workspace:examples/experimental/wasm":
version: 0.0.0-use.local
- resolution: "example-with-wasm@workspace:examples/with-wasm"
+ resolution: "example-wasm@workspace:examples/experimental/wasm"
dependencies:
"@nuxt/ui": "npm:@nuxt/ui-edge@latest"
nuxt3: latest
From 96ad9cfe97da4e386c03dbe38c7fbfb43868ab9a Mon Sep 17 00:00:00 2001
From: Anthony Fu
Date: Thu, 31 Mar 2022 00:00:08 +0800
Subject: [PATCH 11/45] docs: init testing section (#3930)
---
docs/content/3.docs/4.advanced/5.testing.md | 190 ++++++++++++++++++++
packages/test-utils/src/context.ts | 4 +-
2 files changed, 192 insertions(+), 2 deletions(-)
create mode 100644 docs/content/3.docs/4.advanced/5.testing.md
diff --git a/docs/content/3.docs/4.advanced/5.testing.md b/docs/content/3.docs/4.advanced/5.testing.md
new file mode 100644
index 00000000000..8f7dcbf2078
--- /dev/null
+++ b/docs/content/3.docs/4.advanced/5.testing.md
@@ -0,0 +1,190 @@
+# Testing
+
+::alert{icon=👉}
+Test utils are still in development and the API and behavior may change. Currently it's for module authors to preview but not yet ready for testing production apps.
+::
+
+In Nuxt 3, we have a rewritten version of `@nuxt/test-utils` available as `@nuxt/test-utils-edge`. We support [Vitest](https://github.com/vitest-dev/vitest) and [Jest](https://jestjs.io/) as the test runner.
+
+## Installation
+
+```bash
+yarn add --dev @nuxt/test-utils-edge vitest
+```
+
+## Setup
+
+In each describe block where you are taking advantage of the `@nuxt/test-utils` helper methods, you will need to set up the test context before beginning.
+
+```ts
+import { describe, test } from 'vitest'
+import { setup, $fetch } from '@nuxt/test-utils-edge'
+
+describe('My test', () => {
+ await setup({
+ // test context options
+ })
+
+ test('my test', () => {
+ // ...
+ })
+})
+```
+
+Behind the scenes, `setup` performs a number of tasks in `beforeAll`, `beforeEach`, `afterEach` and `afterAll` to setup the Nuxt test environment correctly.
+
+## Options
+
+### Nuxt configuration
+
+#### rootDir
+
+Path to a directory with a Nuxt app to be put under test.
+
+* Type: `string`
+* Default: `'.'`
+
+#### configFile
+
+Name of the configuration file.
+
+* Type: `string`
+* Default: `'nuxt.config'
+
+
+
+### Setup timings
+
+#### setupTimeout
+
+The amount of time (in milliseconds) to allow for `setupTest` to complete its work (which could include building or generating files for a Nuxt application, depending on the options that are passed).
+
+* Type: `number`
+* Default: `60000`
+
+### Features to enable
+
+#### server
+
+Whether to launch a server to respond to requests in the test suite.
+
+* Type: `boolean`
+* Default: `true`
+
+#### build
+
+Whether to run a separate build step.
+
+* Type: `boolean`
+* Default: `true` (`false` if `browser` or `server` is disabled)
+
+#### browser
+
+Under the hood, Nuxt test utils uses [`playwright`](https://playwright.dev/) to carry out browser testing. If this option is set, a browser will be launched and can be controlled in the subsequent test suite. (More info can be found [here](/api-reference/browser-testing).)
+
+* Type: `boolean`
+* Default: `false`
+
+#### browserOptions
+
+* Type: `object` with the following properties
+ * **type**: The type of browser to launch - either `chromium`, `firefox` or `webkit`
+ * **launch**: `object` of options that will be passed to playwright when launching the browser. See [full API reference](https://playwright.dev/#version=master&path=docs%2Fapi.md&q=browsertypelaunchoptions).
+
+#### runner
+
+Specify the runner for the test suite. Currently [Vitest](https://vitest.dev/) is recommend.
+
+* Type: `'vitest' | 'jest'`
+* Default: `'vitest'`
+
+## APIs
+
+### APIs for rendering testing
+
+#### $fetch(url)
+
+Get the HTML of a server-rendered page.
+
+```ts
+import { $fetch } from '@nuxt/test-utils'
+
+const html = await $fetch('/')
+```
+
+#### fetch(url)
+
+Get the response of a server-rendered page.
+
+```ts
+import { fetch } from '@nuxt/test-utils'
+
+const res = await fetch('/')
+const { body, headers } = res
+```
+
+#### url(path)
+
+Get the full URL for a given page (including the port the test server is running on.)
+
+```ts
+import { url } from '@nuxt/test-utils'
+
+const pageUrl = url('/page')
+// 'http://localhost:6840/page'
+```
+
+## Testing Modules
+
+### Fixture Setup
+
+To test the modules we create, we could setup some Nuxt apps as fixtures and test their behaviors. For example, we can create a simple Nuxt app under `./test/fixture` with the configuration like:
+
+```ts
+// nuxt.config.js
+import { defineNuxtConfig } from 'nuxt3'
+import MyModule from '../../src'
+
+export default defineNuxtConfig({
+ modules: [
+ MyModule
+ ]
+})
+```
+
+### Tests Setup
+
+We can create a test file and use the `rootDir` to test the fixture.
+
+```ts
+// basic.test.js
+import { describe, it } from 'vitest'
+import { setup, $fetch } from '@nuxt/test-utils-edge'
+
+describe('ssr', async () => {
+ await setup({
+ rootDir: fileURLToPath(new URL('./fixture', import.meta.url)),
+ })
+
+ it('renders the index page', async () => {
+ // Get response to a server-rendered page with `$fetch`.
+ const html = await $fetch('/')
+
+ expect(html).toContain('A Link')
+ })
+})
+```
+
+For more usage, please reference to our [tests for Nuxt 3 framework](https://github.com/nuxt/framework/blob/main/test/basic.test.ts).
+
+## Testing in a browser
+
+::alert{icon=🚧}
+We are working on it, stay tuned!
+::
diff --git a/packages/test-utils/src/context.ts b/packages/test-utils/src/context.ts
index 5f3faad37df..d203f865b49 100644
--- a/packages/test-utils/src/context.ts
+++ b/packages/test-utils/src/context.ts
@@ -12,8 +12,8 @@ export function createTestContext (options: Partial): TestContext {
setupTimeout: 60000,
dev: !!JSON.parse(process.env.NUXT_TEST_DEV || 'false'),
logLevel: 1,
- server: options.browser,
- build: options.browser || options.server,
+ server: true,
+ build: (options.browser !== false) || (options.server !== false),
nuxtConfig: {},
// TODO: auto detect based on process.env
runner: 'vitest',
From 1a39eff50243a727a130b00dc604d3296121d3f8 Mon Sep 17 00:00:00 2001
From: Daniel Roe
Date: Wed, 30 Mar 2022 18:32:30 +0100
Subject: [PATCH 12/45] docs: update migration guide for nuxt 3 (#3819)
Co-authored-by: Dan Pastori
Co-authored-by: Anthony Fu
Co-authored-by: pooya parsa
---
.../{5.commands.md => 3.commands.md} | 0
.../{3.bridge.md => 4.bridge.md} | 4 +-
...ion-api.md => 5.bridge-composition-api.md} | 0
docs/content/1.getting-started/6.migration.md | 132 -------------
docs/content/2.concepts/1.introduction.md | 4 +-
.../content/2.concepts/2.vuejs-development.md | 2 +-
docs/content/2.concepts/3.rendering.md | 6 +-
.../3.docs/2.directory-structure/3.assets.md | 2 +-
docs/content/3.docs/3.migration/1.overview.md | 21 +++
.../content/3.docs/3.migration/10.bundling.md | 23 +++
docs/content/3.docs/3.migration/11.server.md | 12 ++
.../3.docs/3.migration/2.configuration.md | 97 ++++++++++
.../3.docs/3.migration/20.module-authors.md | 89 +++++++++
.../3.docs/3.migration/3.auto-imports.md | 17 ++
docs/content/3.docs/3.migration/4.meta.md | 106 +++++++++++
.../3.migration/5.plugins-and-middleware.md | 73 ++++++++
.../3.docs/3.migration/6.pages-and-layouts.md | 174 ++++++++++++++++++
.../3.docs/3.migration/7.component-options.md | 148 +++++++++++++++
.../3.docs/3.migration/8.runtime-config.md | 49 +++++
docs/content/3.docs/3.migration/index.md | 6 +
.../{3.deployment => 8.deployment}/1.azure.md | 0
.../2.cloudflare.md | 0
.../3.firebase.md | 0
.../4.netlify.md | 0
.../{3.deployment => 8.deployment}/5.pm2.md | 0
.../6.vercel.md | 0
.../99.presets.md | 0
.../99.presets/custom.md | 0
.../99.presets/lambda.md | 0
.../99.presets/node.md | 0
.../99.presets/server.md | 0
.../99.presets/service-worker.md | 0
.../{3.deployment => 8.deployment}/index.md | 0
.../{4.advanced => 9.advanced}/1.nuxt.md | 0
.../{4.advanced => 9.advanced}/2.modules.md | 0
.../{4.advanced => 9.advanced}/3.kit.md | 0
.../{4.advanced => 9.advanced}/4.hooks.md | 0
37 files changed, 824 insertions(+), 141 deletions(-)
rename docs/content/1.getting-started/{5.commands.md => 3.commands.md} (100%)
rename docs/content/1.getting-started/{3.bridge.md => 4.bridge.md} (99%)
rename docs/content/1.getting-started/{4.bridge-composition-api.md => 5.bridge-composition-api.md} (100%)
delete mode 100644 docs/content/1.getting-started/6.migration.md
create mode 100644 docs/content/3.docs/3.migration/1.overview.md
create mode 100644 docs/content/3.docs/3.migration/10.bundling.md
create mode 100644 docs/content/3.docs/3.migration/11.server.md
create mode 100644 docs/content/3.docs/3.migration/2.configuration.md
create mode 100644 docs/content/3.docs/3.migration/20.module-authors.md
create mode 100644 docs/content/3.docs/3.migration/3.auto-imports.md
create mode 100644 docs/content/3.docs/3.migration/4.meta.md
create mode 100644 docs/content/3.docs/3.migration/5.plugins-and-middleware.md
create mode 100644 docs/content/3.docs/3.migration/6.pages-and-layouts.md
create mode 100644 docs/content/3.docs/3.migration/7.component-options.md
create mode 100644 docs/content/3.docs/3.migration/8.runtime-config.md
create mode 100644 docs/content/3.docs/3.migration/index.md
rename docs/content/3.docs/{3.deployment => 8.deployment}/1.azure.md (100%)
rename docs/content/3.docs/{3.deployment => 8.deployment}/2.cloudflare.md (100%)
rename docs/content/3.docs/{3.deployment => 8.deployment}/3.firebase.md (100%)
rename docs/content/3.docs/{3.deployment => 8.deployment}/4.netlify.md (100%)
rename docs/content/3.docs/{3.deployment => 8.deployment}/5.pm2.md (100%)
rename docs/content/3.docs/{3.deployment => 8.deployment}/6.vercel.md (100%)
rename docs/content/3.docs/{3.deployment => 8.deployment}/99.presets.md (100%)
rename docs/content/3.docs/{3.deployment => 8.deployment}/99.presets/custom.md (100%)
rename docs/content/3.docs/{3.deployment => 8.deployment}/99.presets/lambda.md (100%)
rename docs/content/3.docs/{3.deployment => 8.deployment}/99.presets/node.md (100%)
rename docs/content/3.docs/{3.deployment => 8.deployment}/99.presets/server.md (100%)
rename docs/content/3.docs/{3.deployment => 8.deployment}/99.presets/service-worker.md (100%)
rename docs/content/3.docs/{3.deployment => 8.deployment}/index.md (100%)
rename docs/content/3.docs/{4.advanced => 9.advanced}/1.nuxt.md (100%)
rename docs/content/3.docs/{4.advanced => 9.advanced}/2.modules.md (100%)
rename docs/content/3.docs/{4.advanced => 9.advanced}/3.kit.md (100%)
rename docs/content/3.docs/{4.advanced => 9.advanced}/4.hooks.md (100%)
diff --git a/docs/content/1.getting-started/5.commands.md b/docs/content/1.getting-started/3.commands.md
similarity index 100%
rename from docs/content/1.getting-started/5.commands.md
rename to docs/content/1.getting-started/3.commands.md
diff --git a/docs/content/1.getting-started/3.bridge.md b/docs/content/1.getting-started/4.bridge.md
similarity index 99%
rename from docs/content/1.getting-started/3.bridge.md
rename to docs/content/1.getting-started/4.bridge.md
index 852215a2ee8..e7f5b1e20f7 100644
--- a/docs/content/1.getting-started/3.bridge.md
+++ b/docs/content/1.getting-started/4.bridge.md
@@ -1,4 +1,4 @@
-# Bridge
+# Migrating to Bridge
Experience Nuxt 3 features on existing Nuxt 2 projects.
@@ -241,7 +241,7 @@ export default defineNuxtConfig({
// -- Opt-in features --
- // Use Vite as the bundler instead of Webpack 4
+ // Use Vite as the bundler instead of webpack 4
// vite: true,
// Enable Nuxt 3 compatible useMeta
diff --git a/docs/content/1.getting-started/4.bridge-composition-api.md b/docs/content/1.getting-started/5.bridge-composition-api.md
similarity index 100%
rename from docs/content/1.getting-started/4.bridge-composition-api.md
rename to docs/content/1.getting-started/5.bridge-composition-api.md
diff --git a/docs/content/1.getting-started/6.migration.md b/docs/content/1.getting-started/6.migration.md
deleted file mode 100644
index 53d86e888a7..00000000000
--- a/docs/content/1.getting-started/6.migration.md
+++ /dev/null
@@ -1,132 +0,0 @@
-# Migration
-
-Nuxt 3 migration guide. Work in progress 🚧
-
-## Nuxt 2 to Nuxt 3
-
-At the moment, there is no Nuxt 2 to Nuxt 3 migration guide nor is it recommended due to potentially more changes coming.
-We are working to provide a stable migration guide and tooling to make it as smooth as possible. Please check [Bridge](/getting-started/bridge) for the alternative.
-
-Some features have been dropped from Nuxt 2, some are yet to be implemented for Nuxt 3 and some are new in Nuxt 3 (and Bridge).
-
-Noticeable and/or breaking changes for Nuxt 3 other than the requirements of Nuxt Bridge are:
-
-::list{type=warning}
-
-- Vue app templates are rewritten
-- Vue upgraded to `3.x`
-- Using `` for async data fetching
-- Webpack `5.x` (if not using `vite`)
-- Components discovery is rewritten
-- Introduced main [`app.vue` component](/docs/directory-structure/app)
-- Introduced new [`layouts` system](/docs/directory-structure/layouts)
-- The [`pages/` directory](/docs/directory-structure/pages) conventions changed
-::
-
-The below table highlights an overall feature comparison:
-
-Feature / Version | Nuxt 2 | Nuxt 3 | Changes required | More information
---------------------------|---------|----------|---------------------------------|------------------
-Vue Version | 2 | 3 | Yes |
-`app.vue` | ❌ | ✅ | - |
-Suspense | ❌ | ✅ | - |
-Assets | ✅ | ✅ | No |
-Components | ✅ | ✅ | No |
-Layouts | ✅ | ✅ | Yes |
-Middleware | ✅ | ✅ | Yes |
-Pages | ✅ | ✅ | Yes |
-Pages: Dynamic Params | ✅ | ✅ | Yes |
-Pages: _.vue | ✅ | ✅ | Yes (new naming system) |
-Plugins | ✅ | ✅ | Yes (compatible by default) |
-Transitions | ✅ | ✅ | ? |
-Options API: `asyncData` | ✅ | ✅ | Yes (use `defineNuxtComponent`) |
-Options API: `fetch` | ✅ | ❌ | Use `asyncData` instead |
-Error Pages | ✅ | 🚧 | Yes | [Handling runtime errors](https://github.com/nuxt/framework/discussions/559)
-Store | ✅ | 🚧 | Yes | [Global store support](https://github.com/nuxt/framework/discussions/571)
-Static builds | ✅ | 🚧 | | [Route Caching rules (Hybrid)](https://github.com/nuxt/framework/discussions/560)
-
-### Module Compatibility
-
-All Nuxt 2 modules should be forward compatible with Nuxt 3 as long as they migrate to bridge or if they are already following guidelines.
-
-All (upcoming) modules made with `@nuxt/kit` should be backward compatible with Nuxt 2 projects (even without bridge) as long as they are not depending on a Nuxt 3 / Bridge-only feature.
-
-### Plugin Compatibility
-
-Most Nuxt 2 plugins should be forward compatible with Nuxt 3 with a magical compat layer we inject.
-
-Nuxt 3 plugins are **not** backward compatible with Nuxt 2.
-
-### Vue Compatibility
-
-For plugins using composition API or components, it needs exclusive Vue 2 or Vue 3 support.
-
-By using [vue-demi](https://github.com/vueuse/vue-demi) they should be compatible with both Nuxt 2 and 3.
-
-## Module Migration
-
-When Nuxt 3 users add your module, a compatible module container layer from `@nuxt/kit` is **automatically injected**, so as long as your code is following the guidelines below, it should continue working as-is.
-
-### Test with `@nuxt/bridge`
-
-Migrating to `@nuxt/bridge` is the first and most important step for supporting Nuxt 3.
-
-If you have a fixture or example in your module, add `@nuxt/bridge` package to its config (see [example](/getting-started/bridge#update-nuxtconfig))
-
-### Migrate from CommonJS to ESM
-
-Nuxt 3 natively supports TypeScript and ECMAScript Modules. Please check [Native ES Modules](/concepts/esm) for more info and upgrading.
-
-### Ensure plugins default export
-
-If you inject a Nuxt plugin that does not have `export default` (such as global Vue plugins), ensure you add `export default () => { }` to the end of it.
-
-::code-group
-
-```js [Before]
-// ~/plugins/vuelidate.js
-import Vue from 'vue'
-import Vuelidate from 'vuelidate'
-
-Vue.use(Vuelidate)
-```
-
-```js [After]
-// ~/plugins/vuelidate.js
-import Vue from 'vue'
-import Vuelidate from 'vuelidate'
-
-Vue.use(Vuelidate)
-
-export default () => { }
-```
-
-::
-
-### Avoid runtime modules
-
-With Nuxt 3, Nuxt is now a build-time-only dependency, which means that modules shouldn't attempt to hook into the Nuxt runtime.
-
-Your module should work even if it's only added to [`buildModules`](/docs/directory-structure/nuxt.config#buildmodules) (instead of `modules`). For example:
-
-- Avoid updating `process.env` within a Nuxt module and reading by a nuxt plugin; use [`runtimeConfig`](/docs/directory-structure/nuxt.config#publicruntimeconfig) instead.
-- (*) Avoid depending on runtime hooks like `vue-renderer:*` for production
-- (*) Avoid adding `serverMiddleware` by importing them inside the module. Instead, add them by referencing a file path so that they are independent of the module's context
-
-(*) Unless it is for `nuxt dev` purpose only and guarded with `if (nuxt.options.dev) { }`.
-
-::alert{type=info icon=🔎}
-Continue reading about Nuxt 3 modules in the [Modules guide](/docs/advanced/modules).
-::
-
-### Use TypeScript (optional)
-
-While it is not essential, most of the Nuxt ecosystem is shifting to use TypeScript, so it is highly recommended to consider migration.
-
-::alert{icon=💡}
-You can start migration by renaming `.js` files, to `.ts`. TypeScript is designed to be progressive!
-::
-
-::alert{icon=💡}
-You can use TypeScript syntax for Nuxt 2 and 3 modules and plugins without any extra dependencies.
-::
diff --git a/docs/content/2.concepts/1.introduction.md b/docs/content/2.concepts/1.introduction.md
index a22c8ba0b6d..fb47ee6761a 100644
--- a/docs/content/2.concepts/1.introduction.md
+++ b/docs/content/2.concepts/1.introduction.md
@@ -8,7 +8,7 @@ To understand what is Nuxt, we need to understand what we need to create a moder
::list{type=success}
- A JavaScript framework to bring reactivity and web components, we chose [Vue.js](https://v3.vuejs.org).
-- A bundler to support hot module replacement in development and bundle your code for production, we support both [Webpack 5](https://webpack.js.org/) and [Vite](https://vitejs.dev/).
+- A bundler to support hot module replacement in development and bundle your code for production, we support both [webpack 5](https://webpack.js.org/) and [Vite](https://vitejs.dev/).
- A transpiler in order to write the latest JavaScript syntax while supporting legacy browsers, we use [esbuild](https://esbuild.github.io) for that.
- A server for serving your application in development, but also to support [server-side rendering](https://vuejs.org/api/ssr.html#server-side-rendering-api) or API routes, Nuxt uses [h3](https://github.com/unjs/h3) for deployment versatility such as serverless, workers, Node.js and unmatched performance.
- A routing library to handle client-side navigation, we chose [vue-router](https://router.vuejs.org/).
@@ -47,4 +47,4 @@ Ready to try? Head over the [Installation section](/getting-started/installation
### Are you *courageously* Nuxt?
-Take a stab at an open [issue](https://github.com/nuxt/framework/issues). This is actually the best way to learn Nuxt, by actually diving into the code. You may even bring an approach or alternative solution that makes Nuxt even better! So, what are you waiting for? Let's go!
+Take a stab at an open [issue](https://github.com/nuxt/framework/issues). This is actually the best way to learn Nuxt, by actually diving into the code. You may even bring an approach or alternative solution that makes Nuxt even better! So, what are you waiting for? Let's go!
diff --git a/docs/content/2.concepts/2.vuejs-development.md b/docs/content/2.concepts/2.vuejs-development.md
index 0880aa879b5..73686ccc499 100644
--- a/docs/content/2.concepts/2.vuejs-development.md
+++ b/docs/content/2.concepts/2.vuejs-development.md
@@ -100,7 +100,7 @@ Used with the `setup` keyword in the `
+```
+
+```vue [Nuxt 3]
+
+```
+
+::
+
+### Example: built-in meta-components
+
+Nuxt 3 also provides meta components that you can use to accomplish the same task. While these components look similar to HTML tags, they are provided by Nuxt and have similar functionality.
+
+::code-group
+
+```vue [Nuxt 2]
+
+```
+
+```vue [Nuxt 3]
+
+
+
+ My App
+
+
+
+
+
+```
+
+::
+
+::alert{icon=👉}
+
+1. Make sure you use capital letters for these component names to distinguish them from native HTML elements (`` rather than ``).
+1. You can place these components anywhere in your template for your page.
+::
diff --git a/docs/content/3.docs/3.migration/5.plugins-and-middleware.md b/docs/content/3.docs/3.migration/5.plugins-and-middleware.md
new file mode 100644
index 00000000000..e848a16af77
--- /dev/null
+++ b/docs/content/3.docs/3.migration/5.plugins-and-middleware.md
@@ -0,0 +1,73 @@
+# Plugins and Middleware
+
+## Plugins
+
+Plugins now have a different format, and take only one argument (`nuxtApp`). Read more in [the docs](/docs/directory-structure/plugins).
+
+::code-group
+
+```js [Nuxt 2]
+export default (ctx, inject) => {
+ inject('injected', () => 'my injected function')
+})
+```
+
+```ts [Nuxt 3]
+export default defineNuxtPlugin(nuxtApp => {
+ // now available on `nuxtApp.$injected`
+ nuxtApp.provide('injected', () => 'my injected function')
+
+ // You can alternatively use this format, which comes with automatic type support
+ return {
+ provide: {
+ injected: () => 'my injected function'
+ }
+ }
+})
+```
+
+::
+
+::alert{icon=👉}
+You can read more about the format of `nuxtApp` in [the docs](/docs/usage/nuxt-app).
+::
+
+### Migration
+
+1. Migrate your plugins to use the `defineNuxtPlugin` helper function.
+1. Remove any entries in your `nuxt.config` plugins array that are located in your `plugins/` folder. All files in this directory at the top level (and any index files in any subdirectories) will be automatically registered. Instead of setting `mode` to `client` or `server`, you can indicate this in the file name. For example, `~/plugins/my-plugin.client.ts` will only be loaded on client-side.
+
+## Route middleware
+
+Route middleware has a different format.
+
+::code-group
+
+```js [Nuxt 2]
+export default function ({ store, redirect }) {
+ // If the user is not authenticated
+ if (!store.state.authenticated) {
+ return redirect('/login')
+ }
+}
+```
+
+```ts [Nuxt 3]
+export default defineNuxtRouteMiddleware((to, from) => {
+ const auth = useState('auth')
+ if (!auth.value.authenticated) {
+ return navigateTo('/login')
+ }
+})
+```
+
+::
+
+Much like Nuxt 2, route middleware placed in your `~/middleware` folder is automatically registered. You can then specify it by name in a component. However, this is done with `definePageMeta` rather than as a component option.
+
+`navigateTo` is one of a number of route helper functions, which you can read more about in [the documentation about route middleware](/docs/directory-structure/middleware).
+
+### Migration
+
+1. Migrate your route middleware to use the `defineNuxtRouteMiddleware` helper function.
+1. Any global middleware (such as in your `nuxt.config`) can be placed in your `~/middleware` folder with a `.global` extension, for example `~/middleware/auth.global.ts`.
diff --git a/docs/content/3.docs/3.migration/6.pages-and-layouts.md b/docs/content/3.docs/3.migration/6.pages-and-layouts.md
new file mode 100644
index 00000000000..aee31e2160c
--- /dev/null
+++ b/docs/content/3.docs/3.migration/6.pages-and-layouts.md
@@ -0,0 +1,174 @@
+# Pages and Layouts
+
+## `app.vue`
+
+Nuxt 3 provides a central entrypoint to your app via `~/app.vue`. If you don't have an `app.vue` file in your source directory, Nuxt will use its own default version.
+
+This file is a great place to put any custom code that needs to be run once when your app starts up, as well as any components that are present on every page of your app. For example, if you only have one layout, you can move this to `app.vue` instead.
+
+[Read more about `app.vue`](/docs/directory-structure/app).
+
+### Migration
+
+1. Consider creating an `app.vue` file and including any logic that needs to run once at the top-level of your app. You can check out [an example here](/docs/directory-structure/app).
+
+## Layouts
+
+If you are using layouts in your app for multiple pages, there is only a slight change required.
+
+In Nuxt 2, the `` component is used within a layout to render the current page. In Nuxt 3, layouts use slots instead, so you will have to replace that component with a ``. This also allows advanced use cases with named and scoped slots. [Read more about layouts](/docs/directory-structure/layouts).
+
+You will also need to change how you define the layout used by a page using the `definePageMeta` compiler macro. Layouts will be kebab-cased. So `layouts/customLayout.vue` becomes `custom-layout` when referenced in your page.
+
+### Migration
+
+1. Replace `` with ``
+1. Use `definePageMeta` to select the layout used by your page.
+1. Move `~/layouts/_error.vue` to `~/error.vue`. See [the error handling docs](/docs/usage/error-handling).
+
+### Example: `~/layouts/custom.vue`
+
+::code-group
+
+```diff [layouts/custom.vue]
+
+
+
+-
++
+
+
+
+```
+
+```diff [pages/index.vue]
+
+```
+
+::
+
+## Pages
+
+Nuxt 3 ships with an optional `vue-router` integration triggered by the existence of a `pages/` directory in your source directory. If you only have a single page, you may consider instead moving it to `app.vue` for a lighter build.
+
+### Dynamic routes
+
+The format for defining dynamic routes in Nuxt 3 is slightly different from Nuxt 2, so you may need to rename some of the files within `pages/`.
+
+1. Where you previously used `_id` to define a dynamic route parameter you now use `[id]`.
+1. Where you previously used `_.vue` to define a catch-all route, you now use `[...slug].vue`.
+
+### Nested routes
+
+In Nuxt 2, you will have defined any nested routes (with parent and child components) using `` and ``. In Nuxt 3, these have been replaced with a single `` component.
+
+### Page keys and keep-alive props
+
+If you were passing a custom page key or keep-alive props to ``, you will now use `definePageMeta` to set these options.
+
+See [more about migrating Nuxt component hooks](/docs/migration/nuxt-hooks).
+
+### Page and layout transitions
+
+If you have been defining transitions for your page or layout directly in your component options, you will now need to use `definePageMeta` to set the transition.
+
+[Read more about `pages/`](/docs/directory-structure/pages).
+
+### Migration
+
+1. Rename any pages with dynamic parameters to match the new format.
+1. Update `` and `` to be ``.
+1. If you're using the Composition API, you can also migrate `this.$route` and `this.$router` to use `useRoute` and `useRouter` composables.
+
+#### Example: Dynamic Routes
+
+::code-group
+
+``` [Nuxt 2]
+- URL: /users
+- Page: /pages/users/index.vue
+
+- URL: /users/some-user-name
+- Page: /pages/users/_user.vue
+- Usage: params.user
+
+- URL: /users/some-user-name/edit
+- Page: /pages/users/_user/edit.vue
+- Usage: params.user
+
+- URL: /users/anything-else
+- Page: /pages/users/_.vue
+- Usage: params.pathMatch
+```
+
+``` [Nuxt 3]
+- URL: /users
+- Page: /pages/users/index.vue
+
+- URL: /users/some-user-name
+- Page: /pages/users/[user].vue
+- Usage: params.user
+
+- URL: /users/some-user-name/edit
+- Page: /pages/users/[user]/edit.vue
+- Usage: params.user
+
+- URL: /users/anything-else
+- Page: /pages/users/[...slug].vue
+- Usage: params.slug
+```
+
+::
+
+#### Example: Nested routes and `definePageMeta`
+
+::code-group
+
+```vue [Nuxt 2]
+
+
+
+
+
+
+
+```
+
+```vue [Nuxt 3]
+
+
+
+
+
+
+
+```
+
+::
+
+## NuxtLink component
+
+Most of the syntax and functionality are the same for the global [NuxtLink](/docs/usage/nuxt-link#nuxtlink) component. If you have been using the shortcut `` format, you should update this to use ``.
+
+`` is now a drop-in replacement for _all_ links, even external ones. You can read more about it, and how to extend it to provide your own link component, [in the docs](/docs/usage/nuxt-link#nuxtlink).
diff --git a/docs/content/3.docs/3.migration/7.component-options.md b/docs/content/3.docs/3.migration/7.component-options.md
new file mode 100644
index 00000000000..57295231eb5
--- /dev/null
+++ b/docs/content/3.docs/3.migration/7.component-options.md
@@ -0,0 +1,148 @@
+# Compponent Options
+
+## `asyncData` and `fetch` component options
+
+Nuxt 3 provides new options for [fetching data from an API](/docs/usage/data-fetching).
+
+
+
+
+### Isomorphic fetch
+
+In Nuxt 2 you might use `@nuxtjs/axios` or `@nuxt/http` to fetch your data - or just the polyfilled global `fetch`.
+
+In Nuxt 3 you can use a globally available `fetch` method that has the same API as [the Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) or `$fetch` method which is using [unjs/ohmyfetch](https://github.com/unjs/ohmyfetch). It has a number of benefits, including:
+
+1. It will handle 'smartly' making [direct API calls](/concepts/server-engine#direct-api-calls) if it's running on the server, or making a client-side call to your API if it's running on the client. (It can also handle calling third-party APIs.)
+
+2. Plus, it comes with convenience features including automatically parsing responses and stringifying data.
+
+You can read more [about direct API calls](/concepts/server-engine#direct-api-calls) or [fetching data](/docs/usage/data-fetching).
+
+### Using composables
+
+Nuxt 3 provides new composables for fetching data: `useAsyncData` and `useFetch`. They each have 'lazy' variants (`useLazyAsyncData` and `useLazyFetch`), which do not block client-side navigation.
+
+In Nuxt 2, you'd fetch your data in your component using a syntax similar to:
+
+```ts
+export default {
+ async asyncData({ params, $http }) {
+ const post = await $http.$get(`https://api.nuxtjs.dev/posts/${params.id}`)
+ return { post }
+ },
+ // or alternatively
+ fetch () {
+ this.post = await $http.$get(`https://api.nuxtjs.dev/posts/${params.id}`)
+ }
+}
+```
+
+Within your methods and templates, you could use the `post` variable similar how you'd use any other piece of data provided by your component.
+
+With Nuxt 3, you can perform this data fetching using composables in your `setup()` method or `
+```
+
+You can now use `post` inside of your Nuxt 3 template, or call `refresh` to update the data.
+
+::alert{type=info}
+Despite the names, `useFetch` is not a direct replacement of the `fetch()` hook. Rather, `useAsyncData` replaces both hooks and is most customizable; it can do more than simply fetching data from an endpoint. `useFetch` is a convenience wrapper around `useAsyncData` for simply fetching data fromn an endpoint.
+::
+
+### Migration
+
+1. Replace the `asyncData` hook with `useAsyncData` or `useFetch` in your page/component.
+1. Replace the `fetch` hook with `useAsyncData` or `useFetch` in your component.
+
+## `head`
+
+See [meta tag migration](/docs/migration/meta).
+
+## `key`
+
+You can now define a key within the `definePageMeta` compiler macro.
+
+```diff [pages/index.vue]
+-
+```
+
+### Migration
+
+1. Migrate `key` from component options to `definePageMeta`.
+
+## `layout`
+
+See [layout migration](/docs/migration/pages-and-layouts).
+
+## `loading`
+
+This feature is not yet supported in Nuxt 3.
+
+## `middleware`
+
+See [middleware migration](/docs/migration/plugins-and-middleware).
+
+## `scrollToTop`
+
+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 `~/app/router.options.ts` (see [docs](/docs/directory-structure/pages/#router-options)) for more info.
+
+## `transition`
+
+See [layout migration](/docs/migration/pages-and-layouts).
+
+## `validate`
+
+There is no longer a validate hook in Nuxt 3. Instead, you can create a custom middleware function, or directly throw an error in the setup function of the page.
+
+```diff [pages/users/[id].vue]
+-
+```
+
+## `watchQuery`
+
+This is not supported in Nuxt 3. Instead, you can directly use a watcher to trigger refetching data.
+
+```vue [pages/users/[id].vue]
+
+```
diff --git a/docs/content/3.docs/3.migration/8.runtime-config.md b/docs/content/3.docs/3.migration/8.runtime-config.md
new file mode 100644
index 00000000000..17999ff85ec
--- /dev/null
+++ b/docs/content/3.docs/3.migration/8.runtime-config.md
@@ -0,0 +1,49 @@
+# Runtime Config
+
+If you wish to reference environment variables within your Nuxt 3 app, you will need to use runtime config.
+
+When referencing these variables within your components, you will have to use the `useRuntimeConfig` composable in your setup method (or Nuxt plugin). In the Nitro portion of your app, you can import directly from `#config`.
+
+[Read more about runtime config](/docs/usage/runtime-config).
+
+## Migration
+
+1. Add any environment variables you use in your app to your `publicRuntimeConfig` or `privateRuntimeConfig`.
+1. Migrate `process.env` to `useRuntimeConfig` throughout the Vue part of your app.
+
+## Example
+
+::code-group
+
+```ts [nuxt.config.ts]
+import { defineNuxtConfig } from 'nuxt3'
+
+export default defineNuxtConfig({
+ publicRuntimeConfig: {
+ BASE_URL: process.env.BASE_URL || 'https://nuxtjs.org'
+ },
+ privateRuntimeConfig: {
+ // variables that can only be accessed on server-side
+ },
+})
+```
+
+```vue [pages/index.vue]
+
+```
+
+```ts [server/api/hello.ts]
+import config from '#config';
+
+export default (req, res) => {
+ // you can now access config.BASE_URL
+ return {
+ baseURL: config.BASE_URL
+ }
+}
+```
+
+::
diff --git a/docs/content/3.docs/3.migration/index.md b/docs/content/3.docs/3.migration/index.md
new file mode 100644
index 00000000000..5fb80179f5a
--- /dev/null
+++ b/docs/content/3.docs/3.migration/index.md
@@ -0,0 +1,6 @@
+---
+navigation.collapse: true
+layout.aside: true
+layout.asideClass: ''
+navigation.redirect: /docs/migration/overview
+---
diff --git a/docs/content/3.docs/3.deployment/1.azure.md b/docs/content/3.docs/8.deployment/1.azure.md
similarity index 100%
rename from docs/content/3.docs/3.deployment/1.azure.md
rename to docs/content/3.docs/8.deployment/1.azure.md
diff --git a/docs/content/3.docs/3.deployment/2.cloudflare.md b/docs/content/3.docs/8.deployment/2.cloudflare.md
similarity index 100%
rename from docs/content/3.docs/3.deployment/2.cloudflare.md
rename to docs/content/3.docs/8.deployment/2.cloudflare.md
diff --git a/docs/content/3.docs/3.deployment/3.firebase.md b/docs/content/3.docs/8.deployment/3.firebase.md
similarity index 100%
rename from docs/content/3.docs/3.deployment/3.firebase.md
rename to docs/content/3.docs/8.deployment/3.firebase.md
diff --git a/docs/content/3.docs/3.deployment/4.netlify.md b/docs/content/3.docs/8.deployment/4.netlify.md
similarity index 100%
rename from docs/content/3.docs/3.deployment/4.netlify.md
rename to docs/content/3.docs/8.deployment/4.netlify.md
diff --git a/docs/content/3.docs/3.deployment/5.pm2.md b/docs/content/3.docs/8.deployment/5.pm2.md
similarity index 100%
rename from docs/content/3.docs/3.deployment/5.pm2.md
rename to docs/content/3.docs/8.deployment/5.pm2.md
diff --git a/docs/content/3.docs/3.deployment/6.vercel.md b/docs/content/3.docs/8.deployment/6.vercel.md
similarity index 100%
rename from docs/content/3.docs/3.deployment/6.vercel.md
rename to docs/content/3.docs/8.deployment/6.vercel.md
diff --git a/docs/content/3.docs/3.deployment/99.presets.md b/docs/content/3.docs/8.deployment/99.presets.md
similarity index 100%
rename from docs/content/3.docs/3.deployment/99.presets.md
rename to docs/content/3.docs/8.deployment/99.presets.md
diff --git a/docs/content/3.docs/3.deployment/99.presets/custom.md b/docs/content/3.docs/8.deployment/99.presets/custom.md
similarity index 100%
rename from docs/content/3.docs/3.deployment/99.presets/custom.md
rename to docs/content/3.docs/8.deployment/99.presets/custom.md
diff --git a/docs/content/3.docs/3.deployment/99.presets/lambda.md b/docs/content/3.docs/8.deployment/99.presets/lambda.md
similarity index 100%
rename from docs/content/3.docs/3.deployment/99.presets/lambda.md
rename to docs/content/3.docs/8.deployment/99.presets/lambda.md
diff --git a/docs/content/3.docs/3.deployment/99.presets/node.md b/docs/content/3.docs/8.deployment/99.presets/node.md
similarity index 100%
rename from docs/content/3.docs/3.deployment/99.presets/node.md
rename to docs/content/3.docs/8.deployment/99.presets/node.md
diff --git a/docs/content/3.docs/3.deployment/99.presets/server.md b/docs/content/3.docs/8.deployment/99.presets/server.md
similarity index 100%
rename from docs/content/3.docs/3.deployment/99.presets/server.md
rename to docs/content/3.docs/8.deployment/99.presets/server.md
diff --git a/docs/content/3.docs/3.deployment/99.presets/service-worker.md b/docs/content/3.docs/8.deployment/99.presets/service-worker.md
similarity index 100%
rename from docs/content/3.docs/3.deployment/99.presets/service-worker.md
rename to docs/content/3.docs/8.deployment/99.presets/service-worker.md
diff --git a/docs/content/3.docs/3.deployment/index.md b/docs/content/3.docs/8.deployment/index.md
similarity index 100%
rename from docs/content/3.docs/3.deployment/index.md
rename to docs/content/3.docs/8.deployment/index.md
diff --git a/docs/content/3.docs/4.advanced/1.nuxt.md b/docs/content/3.docs/9.advanced/1.nuxt.md
similarity index 100%
rename from docs/content/3.docs/4.advanced/1.nuxt.md
rename to docs/content/3.docs/9.advanced/1.nuxt.md
diff --git a/docs/content/3.docs/4.advanced/2.modules.md b/docs/content/3.docs/9.advanced/2.modules.md
similarity index 100%
rename from docs/content/3.docs/4.advanced/2.modules.md
rename to docs/content/3.docs/9.advanced/2.modules.md
diff --git a/docs/content/3.docs/4.advanced/3.kit.md b/docs/content/3.docs/9.advanced/3.kit.md
similarity index 100%
rename from docs/content/3.docs/4.advanced/3.kit.md
rename to docs/content/3.docs/9.advanced/3.kit.md
diff --git a/docs/content/3.docs/4.advanced/4.hooks.md b/docs/content/3.docs/9.advanced/4.hooks.md
similarity index 100%
rename from docs/content/3.docs/4.advanced/4.hooks.md
rename to docs/content/3.docs/9.advanced/4.hooks.md
From df188d77349c0d29f80457c42b2c516449ce2bb0 Mon Sep 17 00:00:00 2001
From: Daniel Roe
Date: Wed, 30 Mar 2022 20:07:26 +0100
Subject: [PATCH 13/45] fix(nuxi): respect `NUXT_PORT` and `NUXT_HOST` vars in
dev mode (#3973)
---
docs/content/3.docs/1.usage/8.cli.md | 2 ++
packages/nuxi/src/commands/dev.ts | 4 ++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/docs/content/3.docs/1.usage/8.cli.md b/docs/content/3.docs/1.usage/8.cli.md
index 4d412b5bdd2..d9f693b4d51 100644
--- a/docs/content/3.docs/1.usage/8.cli.md
+++ b/docs/content/3.docs/1.usage/8.cli.md
@@ -35,6 +35,8 @@ Option | Default | Description
`--ssl-cert` |`null` | Specify a certificate for https.
`--ssl-key` |`null` | Specify the key for the https certificate.
+The port and host can also be set via NUXT_PORT, PORT, NUXT_HOST or HOST environment variables.
+
This command sets `process.env.NODE_ENV` to `development`. To override, define `NODE_ENV` in a `.env` file or as command-line argument.
## Build
diff --git a/packages/nuxi/src/commands/dev.ts b/packages/nuxi/src/commands/dev.ts
index 32ce25e01eb..4e5e2b805a2 100644
--- a/packages/nuxi/src/commands/dev.ts
+++ b/packages/nuxi/src/commands/dev.ts
@@ -23,8 +23,8 @@ export default defineNuxtCommand({
const listener = await server.listen({
clipboard: args.clipboard,
open: args.open || args.o,
- port: args.port || args.p,
- hostname: args.host || args.h,
+ port: args.port || args.p || process.env.NUXT_PORT,
+ hostname: args.host || args.h || process.env.NUXT_HOST,
https: Boolean(args.https),
certificate: (args['ssl-cert'] && args['ssl-key']) && {
cert: args['ssl-cert'],
From cb55efcd98e4903c86cbd8bfd64b618bf23b5a3d Mon Sep 17 00:00:00 2001
From: Daniel Roe
Date: Wed, 30 Mar 2022 20:48:53 +0100
Subject: [PATCH 14/45] docs: tiny typo (#3975)
---
docs/content/3.docs/3.migration/7.component-options.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/content/3.docs/3.migration/7.component-options.md b/docs/content/3.docs/3.migration/7.component-options.md
index 57295231eb5..eaf8fb56a7d 100644
--- a/docs/content/3.docs/3.migration/7.component-options.md
+++ b/docs/content/3.docs/3.migration/7.component-options.md
@@ -1,4 +1,4 @@
-# Compponent Options
+# Component Options
## `asyncData` and `fetch` component options
From 646c2f63f77385ece69e6c72323d1db1acb16ecf Mon Sep 17 00:00:00 2001
From: Pooya Parsa
Date: Thu, 31 Mar 2022 00:27:57 +0200
Subject: [PATCH 15/45] fix(deps): pin vite to 2.8.x
pending for #3974
---
package.json | 2 +-
packages/bridge/package.json | 2 +-
packages/vite/package.json | 2 +-
yarn.lock | 20 ++++++++++----------
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/package.json b/package.json
index 175f1669c58..9831cbdfafe 100644
--- a/package.json
+++ b/package.json
@@ -30,7 +30,7 @@
"jiti": "^1.13.0",
"nitropack-dev": "link:../nitropack",
"nuxt3": "workspace:./packages/nuxt3",
- "vite": "^2.8.6",
+ "vite": "~2.8.6",
"unbuild": "^0.7.2"
},
"devDependencies": {
diff --git a/packages/bridge/package.json b/packages/bridge/package.json
index 824805abe4e..77b749120e1 100644
--- a/packages/bridge/package.json
+++ b/packages/bridge/package.json
@@ -61,7 +61,7 @@
"unplugin": "^0.6.0",
"unplugin-vue2-script-setup": "^0.10.1",
"untyped": "^0.4.3",
- "vite": "^2.8.6",
+ "vite": "~2.8.6",
"vite-plugin-vue2": "^1.9.3",
"vue-template-compiler": "^2.6.14"
},
diff --git a/packages/vite/package.json b/packages/vite/package.json
index 40a2ebabbb8..ce30a0998ba 100644
--- a/packages/vite/package.json
+++ b/packages/vite/package.json
@@ -43,7 +43,7 @@
"rollup-plugin-visualizer": "^5.6.0",
"ufo": "^0.8.1",
"unplugin": "^0.6.0",
- "vite": "^2.8.6",
+ "vite": "~2.8.6",
"vite-node": "^0.8.0"
},
"peerDependencies": {
diff --git a/yarn.lock b/yarn.lock
index b8b7e8a962b..edf17a0ff3e 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2637,7 +2637,7 @@ __metadata:
unplugin: ^0.6.0
unplugin-vue2-script-setup: ^0.10.1
untyped: ^0.4.3
- vite: ^2.8.6
+ vite: ~2.8.6
vite-plugin-vue2: ^1.9.3
vue: ^2
vue-router: ^3
@@ -3341,7 +3341,7 @@ __metadata:
ufo: ^0.8.1
unbuild: latest
unplugin: ^0.6.0
- vite: ^2.8.6
+ vite: ~2.8.6
vite-node: ^0.8.0
vue: 3.2.31
peerDependencies:
@@ -9880,7 +9880,7 @@ __metadata:
languageName: node
linkType: hard
-"esbuild@npm:^0.14.25, esbuild@npm:^0.14.27, esbuild@npm:^0.14.28, esbuild@npm:^0.14.6":
+"esbuild@npm:^0.14.14, esbuild@npm:^0.14.25, esbuild@npm:^0.14.27, esbuild@npm:^0.14.28, esbuild@npm:^0.14.6":
version: 0.14.29
resolution: "esbuild@npm:0.14.29"
dependencies:
@@ -17968,7 +17968,7 @@ __metadata:
languageName: node
linkType: hard
-"postcss@npm:^8, postcss@npm:^8.1.10, postcss@npm:^8.2.15, postcss@npm:^8.3.5, postcss@npm:^8.4.12, postcss@npm:^8.4.7":
+"postcss@npm:^8, postcss@npm:^8.1.10, postcss@npm:^8.2.15, postcss@npm:^8.3.5, postcss@npm:^8.4.12, postcss@npm:^8.4.6, postcss@npm:^8.4.7":
version: 8.4.12
resolution: "postcss@npm:8.4.12"
dependencies:
@@ -21652,13 +21652,13 @@ __metadata:
languageName: node
linkType: hard
-"vite@npm:^2.8.6":
- version: 2.9.0
- resolution: "vite@npm:2.9.0"
+"vite@npm:~2.8.6":
+ version: 2.8.6
+ resolution: "vite@npm:2.8.6"
dependencies:
- esbuild: ^0.14.27
+ esbuild: ^0.14.14
fsevents: ~2.3.2
- postcss: ^8.4.12
+ postcss: ^8.4.6
resolve: ^1.22.0
rollup: ^2.59.0
peerDependencies:
@@ -21677,7 +21677,7 @@ __metadata:
optional: true
bin:
vite: bin/vite.js
- checksum: 2355a5a7a57a86558fb2378b493c98c97218ffdf5c7555df5531147217c8ec804d66434dfed130034c920cb0913cd5f0fa1f5d7756101601558320349c0e1cee
+ checksum: 4b02d133892c98362c10214b7ad518d74b59745889197a2ba0b63260ed083fcef75a447e8fb58dbd2af8747386274b36017983d93031254df6ead38701950dcc
languageName: node
linkType: hard
From aab4be329662cbf2206799668b6b03dc9154e645 Mon Sep 17 00:00:00 2001
From: Pooya Parsa
Date: Thu, 31 Mar 2022 00:29:09 +0200
Subject: [PATCH 16/45] chore(deps): temporary skip vite and h3 auto upgrade
---
renovate.json | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/renovate.json b/renovate.json
index c6dd8986c4e..68ad1cacc60 100644
--- a/renovate.json
+++ b/renovate.json
@@ -15,6 +15,8 @@
"@docus/github",
"@docus/social-image",
"@docus/theme",
- "@docus/twitter"
+ "@docus/twitter",
+ "vite",
+ "h3"
]
}
From 7011117c83964d73d8c226bb74cccc431c1efcfd Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Thu, 31 Mar 2022 00:33:07 +0200
Subject: [PATCH 17/45] chore(deps): update all non-major dependencies (#3962)
Co-authored-by: Renovate Bot
---
package.json | 6 +-
packages/bridge/package.json | 2 +-
packages/nitro/package.json | 2 +-
packages/test-utils/package.json | 2 +-
packages/vite/package.json | 8 +-
yarn.lock | 148 +++++++++++++++----------------
6 files changed, 84 insertions(+), 84 deletions(-)
diff --git a/package.json b/package.json
index 9831cbdfafe..542242d9247 100644
--- a/package.json
+++ b/package.json
@@ -40,8 +40,8 @@
"@types/jsdom": "^16",
"@types/node": "^16.11.26",
"@types/object-hash": "^2",
- "@unocss/reset": "^0.30.7",
- "esbuild": "^0.14.28",
+ "@unocss/reset": "^0.30.8",
+ "esbuild": "^0.14.29",
"eslint": "^8.12.0",
"eslint-plugin-jsdoc": "^38.1.4",
"execa": "^6.1.0",
@@ -55,7 +55,7 @@
"pathe": "^0.2.0",
"typescript": "^4.6.3",
"unbuild": "^0.7.2",
- "vitest": "^0.8.0",
+ "vitest": "^0.8.1",
"vue-router": "^4.0.14",
"vue-tsc": "^0.33.9"
},
diff --git a/packages/bridge/package.json b/packages/bridge/package.json
index 77b749120e1..d95adb3d977 100644
--- a/packages/bridge/package.json
+++ b/packages/bridge/package.json
@@ -25,7 +25,7 @@
"@nuxt/nitro": "3.0.0",
"@nuxt/postcss8": "^1.1.3",
"@nuxt/schema": "3.0.0",
- "@vitejs/plugin-legacy": "^1.7.1",
+ "@vitejs/plugin-legacy": "^1.8.0",
"@vue/composition-api": "^1.4.9",
"@vueuse/head": "^0.7.5",
"acorn": "^8.7.0",
diff --git a/packages/nitro/package.json b/packages/nitro/package.json
index 3627bad27c5..7fb45b51242 100644
--- a/packages/nitro/package.json
+++ b/packages/nitro/package.json
@@ -37,7 +37,7 @@
"defu": "^6.0.0",
"destr": "^1.1.0",
"dot-prop": "^7.2.0",
- "esbuild": "^0.14.28",
+ "esbuild": "^0.14.29",
"etag": "^1.8.1",
"fs-extra": "^10.0.1",
"globby": "^13.1.1",
diff --git a/packages/test-utils/package.json b/packages/test-utils/package.json
index 80820d80e91..3e5e62123c0 100644
--- a/packages/test-utils/package.json
+++ b/packages/test-utils/package.json
@@ -24,7 +24,7 @@
"devDependencies": {
"playwright": "^1.20.1",
"unbuild": "latest",
- "vitest": "^0.8.0"
+ "vitest": "^0.8.1"
},
"peerDependencies": {
"vue": "3.2.31"
diff --git a/packages/vite/package.json b/packages/vite/package.json
index ce30a0998ba..4f4c2638997 100644
--- a/packages/vite/package.json
+++ b/packages/vite/package.json
@@ -20,13 +20,13 @@
},
"dependencies": {
"@nuxt/kit": "3.0.0",
- "@vitejs/plugin-vue": "^2.2.4",
- "@vitejs/plugin-vue-jsx": "^1.3.8",
+ "@vitejs/plugin-vue": "^2.3.1",
+ "@vitejs/plugin-vue-jsx": "^1.3.9",
"autoprefixer": "^10.4.4",
"chokidar": "^3.5.3",
"cssnano": "^5.1.5",
"defu": "^6.0.0",
- "esbuild": "^0.14.28",
+ "esbuild": "^0.14.29",
"escape-string-regexp": "^5.0.0",
"externality": "^0.2.1",
"fs-extra": "^10.0.1",
@@ -44,7 +44,7 @@
"ufo": "^0.8.1",
"unplugin": "^0.6.0",
"vite": "~2.8.6",
- "vite-node": "^0.8.0"
+ "vite-node": "^0.8.1"
},
"peerDependencies": {
"vue": "3.2.31"
diff --git a/yarn.lock b/yarn.lock
index edf17a0ff3e..03539bd3c72 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2599,7 +2599,7 @@ __metadata:
"@types/fs-extra": ^9.0.13
"@types/hash-sum": ^1.0.0
"@types/node-fetch": ^3.0.2
- "@vitejs/plugin-legacy": ^1.7.1
+ "@vitejs/plugin-legacy": ^1.8.0
"@vue/composition-api": ^1.4.9
"@vueuse/head": ^0.7.5
acorn: ^8.7.0
@@ -2938,10 +2938,10 @@ __metadata:
linkType: soft
"@nuxt/kit@npm:@nuxt/kit-edge@latest":
- version: 3.0.0-27477342.43007c6
- resolution: "@nuxt/kit-edge@npm:3.0.0-27477342.43007c6"
+ version: 3.0.0-27477794.df188d7
+ resolution: "@nuxt/kit-edge@npm:3.0.0-27477794.df188d7"
dependencies:
- "@nuxt/schema": "npm:@nuxt/schema-edge@3.0.0-27477342.43007c6"
+ "@nuxt/schema": "npm:@nuxt/schema-edge@3.0.0-27477794.df188d7"
c12: ^0.2.4
consola: ^2.15.3
defu: ^6.0.0
@@ -2959,7 +2959,7 @@ __metadata:
unctx: ^1.1.3
unimport: ^0.1.3
untyped: ^0.4.3
- checksum: 64b4df3cc582d91a9a4fbc577113947728eb3f5d2f78e7ff8ec8c46f447c1604dc919501617501085f523ae7289fe4d34ec077df3e263c3f513d3d73510b9706
+ checksum: 5ab587b56287d0679376e2c4f3fd83929d85890ab8ec68f91b5ef2e59577d966736eeaf559db8b9465115cf301836c5ff50822de509c852d50ef72b615133963
languageName: node
linkType: hard
@@ -3012,7 +3012,7 @@ __metadata:
defu: ^6.0.0
destr: ^1.1.0
dot-prop: ^7.2.0
- esbuild: ^0.14.28
+ esbuild: ^0.14.29
etag: ^1.8.1
fs-extra: ^10.0.1
globby: ^13.1.1
@@ -3100,9 +3100,9 @@ __metadata:
languageName: unknown
linkType: soft
-"@nuxt/schema@npm:@nuxt/schema-edge@3.0.0-27477342.43007c6":
- version: 3.0.0-27477342.43007c6
- resolution: "@nuxt/schema-edge@npm:3.0.0-27477342.43007c6"
+"@nuxt/schema@npm:@nuxt/schema-edge@3.0.0-27477794.df188d7":
+ version: 3.0.0-27477794.df188d7
+ resolution: "@nuxt/schema-edge@npm:3.0.0-27477794.df188d7"
dependencies:
c12: ^0.2.4
create-require: ^1.1.1
@@ -3114,7 +3114,7 @@ __metadata:
std-env: ^3.0.1
ufo: ^0.8.1
unimport: ^0.1.3
- checksum: 6008c95bfce2497c99f3784c27cfba5fe3f1bcb544638d1eebe87386729c8996b7e93ad17cac90a5924839197bfe7a67ddb7c4ea416a9aadeb459b615298a033
+ checksum: f152568803a24daa350358c133c1f6bf904bde81eac3fffef83a2f691ce9b456fb9de74dcc1799d864325c21cd739926f8408000295ce56ec60917bfdceb46e0
languageName: node
linkType: hard
@@ -3209,7 +3209,7 @@ __metadata:
ohmyfetch: ^0.4.15
playwright: ^1.20.1
unbuild: latest
- vitest: ^0.8.0
+ vitest: ^0.8.1
peerDependencies:
vue: 3.2.31
languageName: unknown
@@ -3243,15 +3243,15 @@ __metadata:
linkType: hard
"@nuxt/ui-templates@npm:@nuxt/ui-templates-edge@latest":
- version: 0.0.0-27477526.ee5516a
- resolution: "@nuxt/ui-templates-edge@npm:0.0.0-27477526.ee5516a"
- checksum: 26a0b87823c091c3007afd3a7595791eeb57517571bc50dd591dedc790383519da5737c259a4fa4b21479014293172082634e2f813153c6ac1733a6b3a16513c
+ version: 0.0.0-27477607.6f72fd1
+ resolution: "@nuxt/ui-templates-edge@npm:0.0.0-27477607.6f72fd1"
+ checksum: d29c4d313795983283eccccc4ac42daef80e23c2143748aa43d24cb179ae8271a66a05e1cd2df9b0b28af172ccf20f84341f87e7e7e09d156586b53fc69e63cb
languageName: node
linkType: hard
"@nuxt/ui@npm:@nuxt/ui-edge@latest":
- version: 0.0.0-27477526.ee5516a
- resolution: "@nuxt/ui-edge@npm:0.0.0-27477526.ee5516a"
+ version: 0.0.0-27477607.6f72fd1
+ resolution: "@nuxt/ui-edge@npm:0.0.0-27477607.6f72fd1"
dependencies:
"@iconify-json/carbon": ^1.1.2
"@nuxt/kit": "npm:@nuxt/kit-edge@latest"
@@ -3266,7 +3266,7 @@ __metadata:
"@vueuse/nuxt": ^8.2.0
focus-trap: ^6.7.3
unocss: ^0.30.7
- checksum: 9bc7ecb780b979a97f39bba5c07008dbc52c93738de09bc817dfa0dedd3fc18da723c951affa7c0bc47fe37bbdcae23aa1d02ec65dd9ddd96219046d9b64010f
+ checksum: 173fba03a077c29daa449738dc2f27fd2cbd6440f4e2f1238470774a0ba04afa5bdf911890d737790c8ff15402bf8b0c24a368a0491c4cd94cd83139587aab1d
languageName: node
linkType: hard
@@ -3317,13 +3317,13 @@ __metadata:
"@nuxt/kit": 3.0.0
"@nuxt/schema": 3.0.0
"@types/cssnano": ^5
- "@vitejs/plugin-vue": ^2.2.4
- "@vitejs/plugin-vue-jsx": ^1.3.8
+ "@vitejs/plugin-vue": ^2.3.1
+ "@vitejs/plugin-vue-jsx": ^1.3.9
autoprefixer: ^10.4.4
chokidar: ^3.5.3
cssnano: ^5.1.5
defu: ^6.0.0
- esbuild: ^0.14.28
+ esbuild: ^0.14.29
escape-string-regexp: ^5.0.0
externality: ^0.2.1
fs-extra: ^10.0.1
@@ -3342,7 +3342,7 @@ __metadata:
unbuild: latest
unplugin: ^0.6.0
vite: ~2.8.6
- vite-node: ^0.8.0
+ vite-node: ^0.8.1
vue: 3.2.31
peerDependencies:
vue: 3.2.31
@@ -4931,7 +4931,7 @@ __metadata:
languageName: node
linkType: hard
-"@unocss/reset@npm:0.30.8, @unocss/reset@npm:^0.30.7":
+"@unocss/reset@npm:0.30.8, @unocss/reset@npm:^0.30.7, @unocss/reset@npm:^0.30.8":
version: 0.30.8
resolution: "@unocss/reset@npm:0.30.8"
checksum: cb6a1d65adb09edf2697eda19aae9bece10a557d946abe249a6f96659bccb2a313504382088c214be0c57fcaaa15f9983f3d696527c23fc78018a17dff28514e
@@ -5036,7 +5036,7 @@ __metadata:
languageName: node
linkType: hard
-"@vitejs/plugin-legacy@npm:^1.7.1":
+"@vitejs/plugin-legacy@npm:^1.8.0":
version: 1.8.0
resolution: "@vitejs/plugin-legacy@npm:1.8.0"
dependencies:
@@ -5051,7 +5051,7 @@ __metadata:
languageName: node
linkType: hard
-"@vitejs/plugin-vue-jsx@npm:^1.3.8":
+"@vitejs/plugin-vue-jsx@npm:^1.3.9":
version: 1.3.9
resolution: "@vitejs/plugin-vue-jsx@npm:1.3.9"
dependencies:
@@ -5065,13 +5065,13 @@ __metadata:
languageName: node
linkType: hard
-"@vitejs/plugin-vue@npm:^2.2.4":
- version: 2.3.0
- resolution: "@vitejs/plugin-vue@npm:2.3.0"
+"@vitejs/plugin-vue@npm:^2.3.1":
+ version: 2.3.1
+ resolution: "@vitejs/plugin-vue@npm:2.3.1"
peerDependencies:
- vite: ^2.9.0
+ vite: ^2.5.10
vue: ^3.2.25
- checksum: 732ef5b08cec12303b254aa15d9f11970a5ea92bdf1314554e5241ed571df9e3b22d554fae5200ef62c88558747d1ae1f2c8814a6bc440e082facc33ab8f5e5b
+ checksum: 7102d80c7b37c5761213ca57a5d50db95bda387dee92a77bd3d0198fd00c47d117ba82761c26a9d40f83e274d6fa8e3932765f5f930e8139848be7b7b176a200
languageName: node
linkType: hard
@@ -5441,12 +5441,12 @@ __metadata:
languageName: node
linkType: hard
-"@vueuse/core@npm:8.2.0, @vueuse/core@npm:^8.2.0":
- version: 8.2.0
- resolution: "@vueuse/core@npm:8.2.0"
+"@vueuse/core@npm:8.2.1, @vueuse/core@npm:^8.2.0":
+ version: 8.2.1
+ resolution: "@vueuse/core@npm:8.2.1"
dependencies:
- "@vueuse/metadata": 8.2.0
- "@vueuse/shared": 8.2.0
+ "@vueuse/metadata": 8.2.1
+ "@vueuse/shared": 8.2.1
vue-demi: "*"
peerDependencies:
"@vue/composition-api": ^1.1.0
@@ -5456,7 +5456,7 @@ __metadata:
optional: true
vue:
optional: true
- checksum: 7646ac663fd1c2fc7d24bf1355a3077a0e9fc854b84b9de52562905262cf08f3562f417f646c68f275ee3076fe579c17a1533ed18c5f13d08437534d1a612286
+ checksum: e9f6dde3d61db758d1f9523eaf2a8143539a720f0446345494f0a3ae824ca39720a11aaeec927a8d3e12fb3e2cf3a9d1b46b3877ae371ae11336cc25cdf6e921
languageName: node
linkType: hard
@@ -5470,11 +5470,11 @@ __metadata:
linkType: hard
"@vueuse/integrations@npm:^8.2.0":
- version: 8.2.0
- resolution: "@vueuse/integrations@npm:8.2.0"
+ version: 8.2.1
+ resolution: "@vueuse/integrations@npm:8.2.1"
dependencies:
- "@vueuse/core": 8.2.0
- "@vueuse/shared": 8.2.0
+ "@vueuse/core": 8.2.1
+ "@vueuse/shared": 8.2.1
vue-demi: "*"
peerDependencies:
axios: "*"
@@ -5503,33 +5503,33 @@ __metadata:
optional: true
universal-cookie:
optional: true
- checksum: 9d3da5297d861e5df74e927ee4ba5d930dfd490513bf74addeeeaa6b9032e56b67eb68cf4a7bc6b78156adde3e40f98fad2db0d297e8d63df26f8a7d2c919d64
+ checksum: fd2d0f135a9e58402acb7fe2ce4801ab48095b5874f3d1407aa7db58c81e64671eeb68b76df806bab4706363b95d47517b1e10d69440d6e5a021b5768afab93a
languageName: node
linkType: hard
-"@vueuse/metadata@npm:8.2.0":
- version: 8.2.0
- resolution: "@vueuse/metadata@npm:8.2.0"
- checksum: 2f11d2c0408beaffed317a5f418b85e867e8512cc303166915bc2eeee596f0be46d2012e932ce70727dfed7cfa18cdc9e18ae6943ed94710bf50abbc6783ec7d
+"@vueuse/metadata@npm:8.2.1":
+ version: 8.2.1
+ resolution: "@vueuse/metadata@npm:8.2.1"
+ checksum: 602dc6b5be7be21febb85739a7a3c88c310b7670285ee8aa3afddbbe9488d49377ce28efda05514eedf7574956081bd472d0f27bd69c68fdef4b94932c15b66b
languageName: node
linkType: hard
"@vueuse/nuxt@npm:^8.2.0":
- version: 8.2.0
- resolution: "@vueuse/nuxt@npm:8.2.0"
+ version: 8.2.1
+ resolution: "@vueuse/nuxt@npm:8.2.1"
dependencies:
"@nuxt/kit": "npm:@nuxt/kit-edge@latest"
- "@vueuse/core": 8.2.0
- "@vueuse/metadata": 8.2.0
+ "@vueuse/core": 8.2.1
+ "@vueuse/metadata": 8.2.1
local-pkg: ^0.4.1
vue-demi: "*"
- checksum: f8439398aad8768d5ce51047048fae96a9ba6b147c28196f3d3900ae6714d24e138e0a1d759da9f84a97ed4e51d06df94aed9f095d61f3715b7e6a86edbc0fd5
+ checksum: 37500ea1d4da36ab3dee764f6e4f39ce8234363e3ee185b040f9d98713573f1d645c0127e0c2de1da15daa83cbaf849e1b7780154364a28e25c27f51ca71e33a
languageName: node
linkType: hard
-"@vueuse/shared@npm:8.2.0":
- version: 8.2.0
- resolution: "@vueuse/shared@npm:8.2.0"
+"@vueuse/shared@npm:8.2.1":
+ version: 8.2.1
+ resolution: "@vueuse/shared@npm:8.2.1"
dependencies:
vue-demi: "*"
peerDependencies:
@@ -5540,7 +5540,7 @@ __metadata:
optional: true
vue:
optional: true
- checksum: d95e53d5b1d0d2fbc55d1e9b1adeb5908cb93a91c93e43524e254fd69d76c328fe3f544c2b38bec14122baaf863731c0a8d3c3fa1e56df74c238bc158927e64b
+ checksum: 5c5c4591471978f00195b2cf2ef76bc800c227dac5900151af7295cb91833d37500569112a217b2d1d05c94a30778f790f56952b4e1bfeff92a1879390138d08
languageName: node
linkType: hard
@@ -9341,9 +9341,9 @@ __metadata:
linkType: hard
"electron-to-chromium@npm:^1.4.84":
- version: 1.4.101
- resolution: "electron-to-chromium@npm:1.4.101"
- checksum: b4ba580c7e9f6ee4ea8c84524ed1c5279dcabf2d52b72e05aa7d4dc2097b07ada694c05e30d6f1ba0fe9e3788f0f027e9092fd4742967d65b484eb5db1e188f9
+ version: 1.4.102
+ resolution: "electron-to-chromium@npm:1.4.102"
+ checksum: 0df8d3d349e33f454b7b98db8397fffd29f17814a88bba82b9d49f562d3b87fba017115fed074ff2ee89ef00db0dfb5765eac35929fb0e03bc203dd1fa33d5a3
languageName: node
linkType: hard
@@ -9880,7 +9880,7 @@ __metadata:
languageName: node
linkType: hard
-"esbuild@npm:^0.14.14, esbuild@npm:^0.14.25, esbuild@npm:^0.14.27, esbuild@npm:^0.14.28, esbuild@npm:^0.14.6":
+"esbuild@npm:^0.14.14, esbuild@npm:^0.14.25, esbuild@npm:^0.14.27, esbuild@npm:^0.14.29, esbuild@npm:^0.14.6":
version: 0.14.29
resolution: "esbuild@npm:0.14.29"
dependencies:
@@ -13773,9 +13773,9 @@ __metadata:
linkType: hard
"lru-cache@npm:^7.7.1":
- version: 7.7.2
- resolution: "lru-cache@npm:7.7.2"
- checksum: 1aaad83fcffeeed2e08d5b47862e22abe9a2aa065d4e333a0e1944f4125f11acc7a950374ab53a68e61c6188b300f8b4bc59a5f4798d0ca3c9a67b33ea185433
+ version: 7.7.3
+ resolution: "lru-cache@npm:7.7.3"
+ checksum: 1789743a68a8db052564a9dd020f04ba0712327a43e08babc94f05e1c56ef75a03514cf4acab75ae90e3d5d16ae02c7bf0f34754968dc5b8c2c3bc2d92c21745
languageName: node
linkType: hard
@@ -14742,8 +14742,8 @@ __metadata:
linkType: hard
"nitropack@npm:nitropack-edge@latest":
- version: 0.0.0-27477379.ac1b093
- resolution: "nitropack-edge@npm:0.0.0-27477379.ac1b093"
+ version: 0.0.0-27477973.f57f229
+ resolution: "nitropack-edge@npm:0.0.0-27477973.f57f229"
dependencies:
"@cloudflare/kv-asset-handler": ^0.2.0
"@netlify/functions": ^1.0.0
@@ -14808,7 +14808,7 @@ __metadata:
bin:
nitro: ./dist/cli.mjs
nitropack: ./dist/cli.mjs
- checksum: 0acf3321b9cd999d4692937571c8a77a64db750f0c326033a459caa6316015a5ab6b76e967a2d3c7af605cc5871730e69b104b457069184746e70b3c4299a0b0
+ checksum: eb3a0bfb4498740bdd0c19a98b74a61896f7eb925774bbed526551f0d0d399fdd1f884619889162daf2ce2a46e1d21ac4702a1fc02a3595b92c54b95690ba288
languageName: node
linkType: hard
@@ -15435,8 +15435,8 @@ __metadata:
"@types/jsdom": ^16
"@types/node": ^16.11.26
"@types/object-hash": ^2
- "@unocss/reset": ^0.30.7
- esbuild: ^0.14.28
+ "@unocss/reset": ^0.30.8
+ esbuild: ^0.14.29
eslint: ^8.12.0
eslint-plugin-jsdoc: ^38.1.4
execa: ^6.1.0
@@ -15450,7 +15450,7 @@ __metadata:
pathe: ^0.2.0
typescript: ^4.6.3
unbuild: ^0.7.2
- vitest: ^0.8.0
+ vitest: ^0.8.1
vue-router: ^4.0.14
vue-tsc: ^0.33.9
languageName: unknown
@@ -17852,12 +17852,12 @@ __metadata:
linkType: hard
"postcss-selector-parser@npm:^6.0.0, postcss-selector-parser@npm:^6.0.2, postcss-selector-parser@npm:^6.0.4, postcss-selector-parser@npm:^6.0.5, postcss-selector-parser@npm:^6.0.9":
- version: 6.0.9
- resolution: "postcss-selector-parser@npm:6.0.9"
+ version: 6.0.10
+ resolution: "postcss-selector-parser@npm:6.0.10"
dependencies:
cssesc: ^3.0.0
util-deprecate: ^1.0.2
- checksum: f8161ab4d3e5c76b8467189c6d164ba0f6b6e74677435f29e34caa1df01e052b582b4ae4f7468b2243c4befdd8bdcdb7685542d1b2fca8deae21b3e849c78802
+ checksum: 46afaa60e3d1998bd7adf6caa374baf857cc58d3ff944e29459c9a9e4680a7fe41597bd5b755fc81d7c388357e9bf67c0251d047c640a09f148e13606b8a8608
languageName: node
linkType: hard
@@ -21606,7 +21606,7 @@ __metadata:
languageName: node
linkType: hard
-"vite-node@npm:^0.8.0":
+"vite-node@npm:^0.8.1":
version: 0.8.1
resolution: "vite-node@npm:0.8.1"
dependencies:
@@ -21681,7 +21681,7 @@ __metadata:
languageName: node
linkType: hard
-"vitest@npm:^0.8.0":
+"vitest@npm:^0.8.1":
version: 0.8.1
resolution: "vitest@npm:0.8.1"
dependencies:
@@ -21764,8 +21764,8 @@ __metadata:
linkType: hard
"vue-demi@npm:*":
- version: 0.12.4
- resolution: "vue-demi@npm:0.12.4"
+ version: 0.12.5
+ resolution: "vue-demi@npm:0.12.5"
peerDependencies:
"@vue/composition-api": ^1.0.0-rc.1
vue: ^3.0.0-0 || ^2.6.0
@@ -21775,7 +21775,7 @@ __metadata:
bin:
vue-demi-fix: bin/vue-demi-fix.js
vue-demi-switch: bin/vue-demi-switch.js
- checksum: cd715e008837c67aa7018e96f5556ffd4f26cbeed031116251c3983b777ff163550670af28b2b39bc650c5f7c4738976524e013cfc36aa17e26bc07fad70efc5
+ checksum: 40a0470caea8312e0d4df2541f141c36c768dfc7f2f7d41f0f28ba29df11d3119e2f09b94c815f13b7c7f3f45dbc247b0e9e0c02a1800e2823e241c1d771e39b
languageName: node
linkType: hard
From bbfb798f09998e75684f185116fb3addd4211e92 Mon Sep 17 00:00:00 2001
From: Pooya Parsa
Date: Thu, 31 Mar 2022 01:09:18 +0200
Subject: [PATCH 18/45] chore: fix playground without relative path
#2939
---
playground/app.vue | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/playground/app.vue b/playground/app.vue
index 89f65806838..237d3cd4524 100644
--- a/playground/app.vue
+++ b/playground/app.vue
@@ -1,6 +1,6 @@