docs: ensure consistent casing of section headers (#6578)

This commit is contained in:
Damian Głowala 2022-08-13 09:27:04 +02:00 committed by GitHub
parent 47eaaa1a78
commit 92a04cc036
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
85 changed files with 254 additions and 253 deletions

View File

@ -2,7 +2,7 @@
Starting fresh? Getting started with Nuxt 3 is straightforward!
## Play online
## Play Online
You can start playing with Nuxt 3 in your browser using our online sandboxes:
@ -35,7 +35,7 @@ export default defineNuxtConfig({
::
## New project
## New Project
Open a terminal, or from [Visual Studio Code](https://code.visualstudio.com/), open an [integrated terminal](https://code.visualstudio.com/docs/editor/integrated-terminal) and use the following command to create a new starter project:
@ -75,7 +75,7 @@ pnpm install --shamefully-hoist
::
## Development server
## Development Server
Now you'll be able to start your Nuxt app in development mode:
@ -99,7 +99,7 @@ pnpm run dev -o
Well done! A browser window should automatically open for <http://localhost:3000>.
::
## Next steps
## Next Steps
Now that you've created your Nuxt 3 project, you are ready to start building your application.

View File

@ -20,7 +20,7 @@ Nuxt takes care of this so you can focus on what matters: **creating your web ap
On top of this setup, Nuxt provides a [directory structure](/guide/directory-structure) to follow, focused on specific features to keep your focus on creating, not configuring.
## How does it work?
## How Does It Work?
Nuxt is composed of different [core packages](https://github.com/nuxt/framework/tree/main/packages):
::list{type=info}
@ -35,7 +35,7 @@ Nuxt is composed of different [core packages](https://github.com/nuxt/framework/
We recommend reading each concept to have a full vision of Nuxt capabilities and the scope of each package.
## Are you Nuxt?
## Are You Nuxt?
Nuxt is the backbone of your Vue.js project, giving structure to build your project with confidence while keeping flexibility.
@ -45,6 +45,6 @@ Extendable with a strong module ecosystem and hooks engine, it makes it easy to
Ready to try? Head over to the [Installation section](/getting-started/quick-start).
::
### Are you *courageously* Nuxt?
### Are You *Courageously* Nuxt?
Take a stab at an open [issue](https://github.com/nuxt/framework/issues). This is 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!

View File

@ -15,11 +15,11 @@ Nuxt has always used Vue as a frontend framework. We chose to build Nuxt on top
## Vue with Nuxt
### Single file components
### Single File Components
[Vues single-file components](https://v3.vuejs.org/guide/single-file-component.html) (SFC, or `*.vue` files) encapsulate the markup (`<template>`), logic (`<script>`) and styling (`<style>`) of a Vue component. Nuxt provides a zero-config experience for SFCs with [Hot Module Replacement](https://webpack.js.org/concepts/hot-module-replacement/) that offers a seamless developer experience.
### Components auto-imports
### Components Auto-imports
Every Vue component created in the [`components/` directory](/guide/directory-structure/components) of a Nuxt project will be available in your project without having to import it. If a component is not used anywhere, your productions code will not include it.
@ -54,13 +54,13 @@ Nuxt 3 is based on Vue 3. The new major Vue version introduces several changes t
- Composition API
- TypeScript support
### Faster rendering
### Faster Rendering
The Vue Virtual DOM (VDOM) has been rewritten from the ground up and allows for better rendering performance. On top of that, when working with compiled Single-File Components, the Vue compiler can further optimize them at build time by separating static and dynamic markup.
This results in faster first rendering (component creation) and updates, and less memory usage. In Nuxt 3, it enables faster server-side rendering as well.
### Smaller bundle
### Smaller Bundle
With Vue 3 and Nuxt 3, a focus has been put on bundle size reduction. With version 3, most of Vues functionality, including template directives and built-in components, is tree-shakable. Your production bundle will not include them if you dont use them.
@ -103,7 +103,7 @@ The goal of Nuxt 3 is to provide a great developer experience around the Composi
- Use auto-imported [Reactivity functions](https://vuejs.org/api/reactivity-core.html) from Vue and Nuxt 3 [built-in composables](/api/composables/use-async-data).
- Write your own auto-imported reusable functions in the `composables/` directory.
### TypeScript support
### TypeScript Support
Both Vue 3 and Nuxt 3 are written in TypeScript. A fully typed codebase prevents mistakes and documents APIs usage. This doesnt mean that you have to write your application in TypeScript to take advantage of it. With Nuxt 3, you can opt-in by renaming your file from `.js` to `.ts` , or add `<script lang="ts">` in a component.

View File

@ -2,7 +2,7 @@
Both the browser and server can interpret JavaScript code to render Vue.js components into HTML elements. This step is called **rendering**. Nuxt supports both **client-side** and **universal** rendering. The two approaches have pros and cons that we will cover in this section.
## Client-side only rendering
## Client-side Only Rendering
Out of the box, a traditional Vue.js application is rendered in the browser (or **client**). Then, Vue.js generates HTML elements after the browser downloads and parses all the JavaScript code containing the instructions to create the current interface.
@ -71,7 +71,7 @@ At the moment, every page (or **route**) of a Nuxt application must use the same
[Read the open RFC discussing implementation and gathering community feedback.](https://github.com/nuxt/framework/discussions/560)
### Rendering on CDN edge workers
### Rendering on CDN Edge Workers
Traditionally, server-side and universal rendering was only possible using Node.js. Nuxt 3 takes it to another level by directly rendering code in CDN edge workers, reducing latency and costs.

View File

@ -13,7 +13,7 @@ You can find a reference for auto-imported [composables](/api/composables/use-as
Auto imports don't currently work within the [server directory](/guide/directory-structure/server).
::
## Nuxt auto-imports
## Nuxt Auto-imports
Nuxt auto-imports functions and composables to perform [data fetching](/guide/features/data-fetching), get access to the [app context](/api/composables/use-nuxt-app) and [runtime config](/guide/features/runtime-config), manage [state](/guide/features/state-management) or define components and plugins.
@ -24,7 +24,7 @@ Nuxt auto-imports functions and composables to perform [data fetching](/guide/fe
</script>
```
## Vue auto-imports
## Vue Auto-imports
Vue 3 exposes Reactivity APIs like `ref` or `computed`, as well as lifecycle hooks and helpers that are auto-imported by Nuxt.
@ -36,14 +36,14 @@ Vue 3 exposes Reactivity APIs like `ref` or `computed`, as well as lifecycle hoo
</script>
```
## Directory-based auto-imports
## Directory-based Auto-imports
Nuxt directly auto-imports files created in defined directories:
- `components/` for [Vue components](/guide/directory-structure/components).
- `composables/` for [Vue composables](/guide/directory-structure/composables).
## Explicit imports
## Explicit Imports
Nuxt exposes every auto-import with the `#imports` alias that can be used to make the import explicit if needed:

View File

@ -29,7 +29,7 @@ Check out [the h3 docs](https://github.com/unjs/h3) for more information.
Learn more about the API layer in the [`server/`](/guide/directory-structure/server) directory.
::
## Direct API calls
## Direct API Calls
Nitro allows 'direct' calling of routes via the globally-available `$fetch` helper. This will make an API call to the server if run on the browser, but will directly call the relevant function if run on the server, **saving an additional API call**.
@ -40,7 +40,7 @@ Nitro allows 'direct' calling of routes via the globally-available `$fetch` help
For more information on `$fetch` features, check out [ohmyfetch](https://github.com/unjs/ohmyfetch).
## Typed API routes
## Typed API Routes
When using API routes (or middleware), Nitro will generate typings for these routes as long as you are returning a value instead of using `res.end()` to send a response.

View File

@ -10,7 +10,7 @@ By default, Nuxt doesn't check types when you run `nuxi dev` or `nuxi build`, fo
yarn nuxi typecheck
```
## Auto-generated types
## Auto-generated Types
When you run `nuxi dev` or `nuxi build`, Nuxt generates the following files for IDE type support (and type checking):
@ -37,7 +37,7 @@ Overwriting options such as `"compilerOptions.paths"` with your own configuratio
In case you need to extend options provided by `./.nuxt/tsconfig.json` further, you can use the `alias` property within your `nuxt.config`. `nuxi` will pick them up and extend `./.nuxt/tsconfig.json` accordingly.
::
## Stricter checks
## Stricter Checks
TypeScript comes with certain checks to give you more safety and analysis of your program.

View File

@ -2,7 +2,7 @@
Nuxt provides a runtime config API to expose configuration within your application and server routes, with the ability to update it at runtime by setting environment variables.
## Exposing runtime config
## Exposing Runtime Config
To expose config and environment variables to the rest of your app, you will need to define runtime configuration in your `nuxt.config` file, using the [`runtimeConfig` option](/guide/directory-structure/nuxt.config#runtimeconfig).
@ -66,9 +66,9 @@ export default defineNuxtConfig({
})
```
## Accessing runtime config
## Accessing Runtime Config
### Vue app
### Vue App
Within the Vue part of your Nuxt app, you will need to call `useRuntimeConfig()` to access the runtime config.

View File

@ -4,7 +4,7 @@ Vue 3 provides the [`<Teleport>` component](https://vuejs.org/guide/built-ins/te
The `to` target of `<Teleport>` expects a CSS selector string or an actual DOM node. Nuxt currently has SSR support for teleports to `body` only, with client-side support for other targets using a `<ClientOnly>` wrapper.
## Example: body teleport
## Example: `body` Teleport
```vue
<template>
@ -22,9 +22,10 @@ The `to` target of `<Teleport>` expects a CSS selector string or an actual DOM n
</template>
```
## Example: client-side teleport
## Example: Client-side Teleport
```vue
<template>
<ClientOnly>
<Teleport to="#some-selector">
<!-- content -->

View File

@ -6,7 +6,7 @@ Nuxt provides a module system to extend the framework core and simplify integrat
When developing production-grade applications with Nuxt you might find that the framework's core functionality is not enough. Nuxt can be extended with configuration options and plugins, but maintaining these customizations across multiple projects can be tedious, repetitive and time-consuming. On the other hand, supporting every project's needs out of the box would make Nuxt very complex and hard to use.
This is one of the reasons why Nuxt provides a module system that makes it possible to extend the core. Nuxt modules are async functions that sequentially run when starting nuxt in development mode using `nuxi dev` or building a project for production with `nuxi build`. They can override templates, configure webpack loaders, add CSS libraries, and perform many other useful tasks.
This is one of the reasons why Nuxt provides a module system that makes it possible to extend the core. Nuxt modules are async functions that sequentially run when starting Nuxt in development mode using `nuxi dev` or building a project for production with `nuxi build`. They can override templates, configure webpack loaders, add CSS libraries, and perform many other useful tasks.
Best of all, Nuxt modules can be distributed in npm packages. This makes it possible for them to be reused across projects and shared with the community, helping create an ecosystem of high-quality add-ons.
@ -39,7 +39,7 @@ export default defineNuxtConfig({
Nuxt modules are now build-time-only, and the `buildModules` property used in Nuxt 2 is deprecated in favor of `modules`.
::
## Module development
## Module Development
Everyone has the opportunity to develop modules. Read more about developing modules in the [Module Author Guide](/guide/going-further/modules).

View File

@ -5,7 +5,7 @@ Nuxt uses two directories to handle assets like stylesheets, fonts or images:
- The [`public/` directory](/guide/directory-structure/public) content is served at the server root as-is.
- The [`assets/` directory](/guide/directory-structure/assets) contains by convention every asset that you want the build tool (Vite or Webpack) to process.
## `public/` directory
## `public/` Directory
The [`public/` directory](/guide/directory-structure/public) is used as a public server for static assets publicly available at a defined URL of your application.
@ -21,7 +21,7 @@ For example, referencing an image file in the `public/img/` directory, available
</template>
```
## `assets/` directory
## `assets/` Directory
Nuxt uses [Vite](https://vitejs.dev/guide/assets.html) or [Webpack](https://webpack.js.org/guides/asset-management/) to build and bundle your application. The main function of these build tools is to process JavaScript files, but they can be extended through [plugins](https://vitejs.dev/plugins/) (for Vite) or [loaders](https://webpack.js.org/loaders/) (for Webpack) to process other kind of assets, like stylesheets, fonts or SVG. This step transforms the original file mainly for performance or caching purposes (such as stylesheets minification or browser cache invalidation).

View File

@ -98,7 +98,7 @@ const title = ref('Hello World')
</template>
```
## Example: usage with definePageMeta
## Example: Usage With `definePageMeta`
Within your `pages/` directory, you can use `definePageMeta` along with `useHead` to set metadata based on the current route.

View File

@ -180,7 +180,7 @@ When we call `fetch` in the browser, user headers like `cookie` will be directly
::ReadMore{link="/api/utils/$fetch"}
::
### Example: Pass client headers to the API
### Example: Pass Client Headers to the API
We can use [`useRequestHeaders`](/api/composables/use-request-headers) to access and proxy cookies to the API from server-side.
@ -207,7 +207,7 @@ Here is a list of common headers that are NOT to be proxied:
* `cf-connecting-ip`, `cf-ray`
::
### Example: Pass on cookies from server-side API calls on SSR response
### Example: Pass Cookies From Server-side API Calls on SSR Response
If you want to pass on/proxy cookies in the other direction, from an internal request back to the client, you will need to handle this yourself.
@ -234,7 +234,7 @@ onMounted(() => console.log(document.cookie))
</script>
```
## Best practices
## Best Practices
The data returned by these composables will be stored inside the page payload. This means that every key returned that is not used in your component will be added to the payload.
@ -271,7 +271,7 @@ const { data: mountain } = await useFetch('/api/mountains/everest', { pick: ['ti
</template>
```
## Using async setup
## Using Async Setup
If you are using `async setup()`, the current component instance will be lost after the first `await`. (This is a Vue 3 limitation.) If you want to use multiple async operations, such as multiple calls to `useFetch`, you will need to use `<script setup>` or await them together at the end of setup.
@ -304,7 +304,7 @@ export default defineComponent({
</template>
```
## Directly calling an API Endpoint
## Directly Calling an API Endpoint
There are instances where you may need to directly call the API. Nuxt 3 provides a globally available `$fetch` method using [unjs/ohmyfetch](https://github.com/unjs/ohmyfetch) (in addition to `fetch`)
with the same API as the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch).

View File

@ -14,7 +14,7 @@ Nuxt provides `useState` composable to create a reactive and SSR-friendly shared
Because the data inside `useState` will be serialized to JSON, it is important that it does not contain anything that cannot be serialized, such as classes, functions or symbols.
::
## Best practices
## Best Practices
::alert{type=danger icon=🚨}
Never define `const state = ref()` outside of `<script setup>` or `setup()` function.<br>
@ -26,7 +26,7 @@ Instead use `const useX = () => useState('x')`
## Examples
### Basic usage
### Basic Usage
In this example, we use a component-local counter state. Any other component that uses `useState('counter')` shares the same reactive state.
@ -59,7 +59,7 @@ In this example, we use a composable that detects the user's default locale from
:LinkExample{link="/examples/other/locale"}
## Shared state
## Shared State
By using [auto-imported composables](/guide/directory-structure/composables) we can define global type-safe states and import them across the app.

View File

@ -1,6 +1,6 @@
# Error Handling
## Handling errors
## Handling Errors
Nuxt 3 is a full-stack framework, which means there are several sources of unpreventable user runtime errors that can happen in different contexts:
@ -8,7 +8,7 @@ Nuxt 3 is a full-stack framework, which means there are several sources of unpre
1. Errors during API or Nitro server lifecycle
1. Server and client startup errors (SSR + SPA)
### Errors during the Vue rendering lifecycle (SSR + SPA)
### Errors During the Vue Rendering Lifecycle (SSR + SPA)
You can hook into Vue errors using [`onErrorCaptured`](https://vuejs.org/api/composition-api-lifecycle.html#onerrorcaptured).
@ -16,7 +16,7 @@ In addition, Nuxt provides a `vue:error` hook that will be called if any errors
If you are using an error reporting framework, you can provide a global handler through [`vueApp.config.errorHandler`](https://vuejs.org/api/application.html#app-config-errorhandler). It will receive all Vue errors, even if they are handled.
#### Example with global error reporting framework
#### Example With Global Error Reporting Framework
```js
export default defineNuxtPlugin((nuxtApp) => {
@ -26,7 +26,7 @@ export default defineNuxtPlugin((nuxtApp) => {
})
```
### Server and client startup errors (SSR + SPA)
### Server and Client Startup Errors (SSR + SPA)
Nuxt will call the `app:error` hook if there are any errors in starting your Nuxt application.
@ -37,11 +37,11 @@ This includes:
* mounting the app (on client-side), though you should handle this case with `onErrorCaptured` or with `vue:error`
* processing the `app:mounted` hook
### Errors during API or Nitro server lifecycle
### Errors During API or Nitro Server Lifecycle
You cannot currently define a server-side handler for these errors, but can render an error page (see the next section).
## Rendering an error page
## Rendering an Error Page
When Nuxt encounters a fatal error, whether during the server lifecycle, or when rendering your Vue application (both SSR and SPA), it will either render a JSON response (if requested with `Accept: application/json` header) or an HTML error page.
@ -69,7 +69,7 @@ const handleError = () => clearError({ redirect: '/' })
</script>
```
## Error helper methods
## Error Helper Methods
### `useError`
@ -123,7 +123,7 @@ This function will clear the currently handled Nuxt error. It also takes an opti
::ReadMore{link="/api/utils/clear-error"}
::
## Rendering errors within your app
## Rendering Errors Within Your App
Nuxt also provides a `<NuxtErrorBoundary>` component that allows you to handle client-side errors within your app, without replacing your entire site with an error page.

View File

@ -101,7 +101,7 @@ Given the Example above, fetching `/test` with:
- **POST** method: Returns `Test post handler`
- Any other method: Returns 404 error
### Catch-all route
### Catch-all Route
Catch-all routes are helpful for fallback route handling. For example, creating a file named `~/server/api/foo/[...].ts` will register a catch-all route for all requests that do not match any route handler, such as `/api/foo/bar/baz`.
@ -130,7 +130,7 @@ You can now universally call this API using `$fetch('/api/submit', { method: 'po
We are using `submit.post.ts` in the filename only to match requests with `POST` method that can accept the request body. When using `useBody` within a GET request, `useBody` will throw a `405 Method Not Allowed` HTTP error.
::
### Handling Requests with query parameters
### Handling Requests With Query Parameters
Sample query `/api/query?param1=a&param2=b`
@ -141,7 +141,7 @@ export default defineEventHandler((event) => {
})
```
### Get access to the runtimeConfig
### Accessing Runtime Config
```ts [/server/api/foo.ts]
@ -151,7 +151,7 @@ export default defineEventHandler((event) => {
})
```
### Access Request Cookies
### Accessing Request Cookies
```ts
export default defineEventHandler((event) => {
@ -162,7 +162,7 @@ export default defineEventHandler((event) => {
## Advanced Usage Examples
### Using a nested router
### Using a Nested Router
```ts [/server/api/hello.ts]
import { createRouter } from 'h3'
@ -174,7 +174,7 @@ router.get('/', () => 'Hello World')
export default router
```
### Sending streams (experimental)
### Sending Streams (Experimental)
**Note:** This is an experimental feature and available only within Node.js environments.
@ -187,7 +187,7 @@ export default defineEventHandler((event) => {
})
```
### Return a legacy handler or middleware
### Return a Legacy Handler or Middleware
```ts [/server/api/legacy.ts]
export default (req, res) => {

View File

@ -1,11 +1,11 @@
---
icon: IconDirectory
title: '.nuxt'
head.title: Nuxt directory
head.title: Nuxt Directory
---
# Nuxt directory
# Nuxt Directory
Nuxt uses the `.nuxt/` directory in development to generate your Vue application.

View File

@ -1,10 +1,10 @@
---
icon: IconDirectory
title: 'pages'
head.title: Pages directory
head.title: Pages Directory
---
# Pages directory
# Pages Directory
Nuxt provides a file-based routing to create routes within your web application using [Vue Router](https://router.vuejs.org) under the hood.
@ -132,7 +132,7 @@ if (route.params.group === 'admins' && !route.params.id) {
</script>
```
## Catch all route
## Catch-all Route
If you need a catch-all route, you create it by using a file named like `[...slug].vue`. This will match _all_ routes under that path.
@ -195,7 +195,7 @@ To display the `child.vue` component, you have to insert the `<NuxtPage>` com
</template>
```
### Child route keys
### Child Route Keys
If you want more control over when the `<NuxtPage>` component is re-rendered (for example, for transitions), you can either pass a string or function via the `pageKey` prop, or you can define a `key` value via `definePageMeta`:
@ -320,7 +320,7 @@ A simple link to the `index.vue` page in your `pages` folder:
Learn more about [`<NuxtLink>`](/api/components/nuxt-link) usage.
::
## Router options
## Router Options
It is possible to set default [vue-router options](https://router.vuejs.org/api/interfaces/routeroptions.html).

View File

@ -1,10 +1,10 @@
---
icon: IconDirectory
title: 'plugins'
head.title: Plugins directory
head.title: Plugins Directory
---
# Plugins directory
# Plugins Directory
Nuxt will automatically read the files in your `plugins` directory and load them. You can use `.server` or `.client` suffix in the file name to load a plugin only on the server or client side.
@ -12,7 +12,7 @@ Nuxt will automatically read the files in your `plugins` directory and load them
All plugins in your `plugins/` directory are auto-registered, so you should not add them to your `nuxt.config` separately.
::
## Which files are registered
## Which Files Are Registered
Only files at the top level of the `plugins/` directory (or index files within any subdirectories) will be registered as plugins.
@ -29,7 +29,7 @@ plugins
Only `myPlugin.ts` and `myOtherPlugin/index.ts` would be registered.
## Creating plugins
## Creating Plugins
The only argument passed to a plugin is [`nuxtApp`](/api/composables/use-nuxt-app).
@ -39,7 +39,7 @@ export default defineNuxtPlugin(nuxtApp => {
})
```
## Automatically providing helpers
## Automatically Providing Helpers
If you would like to provide a helper on the `NuxtApp` instance, return it from the plugin under a `provide` key. For example:
@ -68,7 +68,7 @@ const { $hello } = useNuxtApp()
</script>
```
## Typing plugins
## Typing Plugins
If you return your helpers from the plugin, they will be typed automatically; you'll find them typed for the return of `useNuxtApp()` and within your templates.
@ -96,7 +96,7 @@ declare module '@vue/runtime-core' {
export { }
```
## Vue plugins
## Vue Plugins
If you want to use Vue plugins, like [vue-gtag](https://github.com/MatteoGabriele/vue-gtag) to add Google Analytics tags, you can use a Nuxt plugin to do so.
@ -122,7 +122,7 @@ export default defineNuxtPlugin((nuxtApp) => {
})
```
## Vue directives
## Vue Directives
Similarly, you can register a custom Vue directive in a plugin. For example, in `plugins/directive.ts`:

View File

@ -1,10 +1,10 @@
---
icon: IconDirectory
title: public
head.title: Public directory
head.title: Public Directory
---
# Public directory
# Public Directory
The `public/` directory is directly served at the server root and contains public files that have to keep their names (e.g. `robots.txt`) _or_ likely won't change (e.g. `favicon.ico`).

View File

@ -1,9 +1,9 @@
---
icon: IconDirectory
title: server
head.title: Server directory
head.title: Server Directory
---
# Server directory
# Server Directory
::ReadMore{link="/guide/features/server-routes"}

View File

@ -1,10 +1,10 @@
---
icon: IconFile
title: .gitignore
head.title: Gitignore file
head.title: Git Ignore File
---
# Gitignore file
# Git Ignore File
A `.gitignore` file specifies intentionally untracked files that git should ignore. Learn more about it in [the git documentation](https://git-scm.com/docs/gitignore).

View File

@ -1,14 +1,14 @@
---
icon: IconFile
title: app.vue
head.title: App file
head.title: App File
---
# App file
# App File
The `app.vue` file is the main component in your Nuxt 3 applications.
## Minimal usage
## Minimal Usage
With Nuxt 3, the [`pages/`](/guide/directory-structure/pages) directory is optional. If not present, Nuxt won't include [vue-router](https://router.vuejs.org/) dependency. This is useful when working on a landing page or an application that does not need routing.
@ -18,7 +18,7 @@ With Nuxt 3, the [`pages/`](/guide/directory-structure/pages) directory is optio
</template>
```
## Usage with pages
## Usage With Pages
If you have a [`pages/`](/guide/directory-structure/pages) directory, to display the current page, use the `<NuxtPage>` component:

View File

@ -1,10 +1,10 @@
---
icon: IconFile
title: .nuxtignore
head.title: .nuxtignore file
head.title: Nuxt Ignore File
---
# Nuxt ignore file
# Nuxt Ignore File
You can use a `.nuxtignore` file to let Nuxt ignore `layout`, `pages`, `components`, `composables` and `middleware` files in your projects root directory (`rootDir`) during the build phase. The `.nuxtignore` file is subject to the same specification as `.gitignore` and `.eslintignore` files, in which each line is a glob pattern indicating which files should be ignored.

View File

@ -1,10 +1,10 @@
---
icon: IconFile
title: nuxt.config.ts
head.title: Nuxt configuration file
head.title: Nuxt Configuration file
---
# Nuxt configuration file
# Nuxt Configuration file
Nuxt can be easily configured with a single `nuxt.config` file, which can have either a `.js`, `.ts` or `.mjs` extension.
@ -16,7 +16,7 @@ export default defineNuxtConfig({
})
```
To ensure your configuration is up to date, nuxt will make a full restart when detecting changes in the nuxt main configuration file, the `.env`, `.nuxtignore` and `.nuxtrc` dotfiles.
To ensure your configuration is up to date, Nuxt will make a full restart when detecting changes in the main configuration file, the `.env`, `.nuxtignore` and `.nuxtrc` dotfiles.
::ReadMore{link="/api/configuration/nuxt.config"}
::

View File

@ -1,9 +1,9 @@
---
icon: IconFile
title: package.json
head.title: Package file
head.title: Package File
---
# Package file
# Package File
The `package.json` file contains all the dependencies and scripts for your application ([learn more](https://docs.npmjs.com/cli/v7/configuring-npm/package-json)).

View File

@ -1,10 +1,10 @@
---
icon: IconFile
title: tsconfig.json
head.title: TypeScript configuration file
head.title: TypeScript Configuration File
---
# TypeScript configuration file
# TypeScript Configuration File
Nuxt [automatically generates](/guide/concepts/typescript) a `.nuxt/tsconfig.json` file with the resolved aliases you are using in your Nuxt project, as well as with other sensible defaults. You can benefit from this by creating a `tsconfig.json` in the root of your project with the following content:

View File

@ -1,10 +1,10 @@
---
icon: IconDirectory
title: '.output'
head.title: Output directory
head.title: Output Directory
---
# Output directory
# Output Directory
Nuxt creates the `.output/` directory when building your application for production.

View File

@ -1,10 +1,10 @@
---
icon: IconDirectory
title: 'assets'
head.title: Assets directory
head.title: Assets Directory
---
# Assets directory
# Assets Directory
The `assets/` directory is used to add all the website's assets that the build tool (webpack or Vite) will process.

View File

@ -1,10 +1,10 @@
---
icon: IconDirectory
title: 'components'
head.title: Components directory
head.title: Components Directory
---
# Components directory
# Components Directory
The `components/` directory is where you put all your Vue components which can then be imported inside your pages or other components ([learn more](https://vuejs.org/guide/essentials/component-basics.html#components-basics)).
@ -47,7 +47,7 @@ If you have a component in nested directories such as:
For clarity, we recommend that the component's filename matches its name. (So, in the example above, you could rename `Button.vue` to be `BaseFooButton.vue`.)
::
## Dynamic components
## Dynamic Components
If you want to use the Vue `<component :is="someComputedComponent">` syntax, then you will need to use the `resolveComponent` helper provided by Vue.
@ -122,7 +122,7 @@ export default {
</script>
```
## Direct imports
## Direct Imports
You can also explicitly import components from `#components` if you want or need to bypass Nuxt's auto-importing functionality.

View File

@ -1,10 +1,10 @@
---
icon: IconDirectory
title: 'composables'
head.title: Composables directory
head.title: Composables Directory
---
# Composables directory
# Composables Directory
Nuxt 3 supports `composables/` directory to automatically import your Vue composables into your application using [auto-imports](/guide/concepts/auto-imports)!
@ -47,7 +47,7 @@ const foo = useFoo()
:LinkExample{link="/examples/auto-imports/composables"}
## How files are scanned
## How Files Are Scanned
Nuxt only scans files at the top level of the `composables/` directory for composables.

View File

@ -1,10 +1,10 @@
---
icon: IconDirectory
title: 'content'
head.title: Content directory
head.title: Content Directory
---
# Content directory
# Content Directory
The [Nuxt Content module](https://content.nuxtjs.org) reads the `content/` directory in your project and parses `.md`, `.yml`, `.csv` and `.json` files to create a file-based CMS for your application.
@ -17,7 +17,7 @@ The [Nuxt Content module](https://content.nuxtjs.org) reads the `content/` direc
::
## Get started
## Get Started
### Installation
@ -54,7 +54,7 @@ export default defineNuxtConfig({
})
```
### Create content
### Create Content
Place your markdown files inside the `content/` directory in the root directory of your project:
@ -64,7 +64,7 @@ Place your markdown files inside the `content/` directory in the root directory
The module automatically loads and parses them.
### Render pages
### Render Pages
To render content pages, add a [catch-all route](/guide/directory-structure/pages/#catch-all-route) using the `ContentDoc` component:

View File

@ -1,10 +1,10 @@
---
icon: IconDirectory
title: 'layouts'
head.title: Layouts directory
head.title: Layouts Directory
---
# Layouts directory
# Layouts Directory
Nuxt provides a customizable layouts framework you can use throughout your application, ideal for extracting common UI or code patterns into reusable layout components.
@ -16,7 +16,7 @@ If you only have a single layout in your application, we recommend using [app.vu
Unlike other components, your layouts must have a single root element to allow Nuxt to apply transitions between layout changes - and this root element cannot be a `<slot />`.
::
## Enabling the default layout
## Enabling the Default Layout
Add a `~/layouts/default.vue`:
@ -41,7 +41,7 @@ If you use a `app.vue` you will also need to add `<NuxtLayout>`:
</template>
```
## Setting another layout
## Setting Another Layout
```bash
-| layouts/
@ -109,7 +109,7 @@ definePageMeta({
Learn more about [defining page meta](/guide/directory-structure/pages#page-metadata).
::
## Changing the layout dynamically
## Changing the Layout Dynamically
You can also use a ref or computed property for your layout.
@ -133,7 +133,7 @@ definePageMeta({
:LinkExample{link="/examples/routing/layouts"}
## Overriding a layout on a per-page basis
## Overriding a Layout on a Per-page Basis
If you are using the `~/pages` integration, you can take full control by setting `layout: false` and then using the `<NuxtLayout>` component within the page.

View File

@ -1,10 +1,10 @@
---
icon: IconDirectory
title: 'middleware'
head.title: Middleware directory
head.title: Middleware Directory
---
# Middleware directory
# Middleware Directory
Nuxt provides a customizable **route middleware** framework you can use throughout your application, ideal for extracting code that you want to run before navigating to a particular route.
@ -60,7 +60,7 @@ Unlike navigation guards in [the vue-router docs](https://router.vuejs.org/guide
We recommend using the helper functions above for performing redirects or stopping navigation. Other possible return values described in [the vue-router docs](https://router.vuejs.org/guide/advanced/navigation-guards.html#global-before-guards) may work but there may be breaking changes in future.
::
## Adding middleware dynamically
## Adding Middleware Dynamically
It is possible to add global or named route middleware manually using the `addRouteMiddleware()` helper function, such as from within a plugin.
@ -76,7 +76,7 @@ export default defineNuxtPlugin(() => {
})
```
## Example: a named route middleware
## Example: A Named Route Middleware
```bash
-| middleware/

View File

@ -1,9 +1,9 @@
---
icon: IconDirectory
title: 'node_modules'
head.title: Node modules directory
head.title: Node Modules Directory
---
# Node modules directory
# Node Modules Directory
The package manager ([`npm`](https://docs.npmjs.com/cli/v7/commands/npm) or [`yarn`](https://yarnpkg.com/) or [`pnpm`](https://pnpm.io/cli/install)) creates the `node_modules` directory to store the dependencies of your project.

View File

@ -1,5 +1,5 @@
---
title: 'Directory structure'
title: 'Directory Structure'
layout.aside: true
layout.asideClass: ''
navigation.redirect: /guide/directory-structure/nuxt

View File

@ -9,7 +9,7 @@ Discover the Node.js server preset with Nitro to deploy on any Node hosting.
- Useful for deploying Nuxt apps to any Node.js hosting
::
## Entry point
## Entry Point
When running `nuxt build` with the Node server preset, the result will be an entry point that launches a ready-to-run Node server.
@ -24,7 +24,7 @@ $ node .output/server/index.mjs
Listening on http://localhost:3000
```
## Configuring defaults at runtime
## Configuring Defaults at Runtime
This preset will respect the following runtime environment variables:
@ -49,6 +49,6 @@ module.exports = {
}
```
## Learn more
## Learn More
:ReadMore{link="https://nitro.unjs.io/deploy/node.html" title="the Nitro documentation for node-server preset"}

View File

@ -17,7 +17,7 @@ Use the [`nuxi generate` command](/api/commands/generate) to build your applicat
npx nuxi generate
```
## Client-side only rendering
## Client-side Only Rendering
If you don't want to prerender your routes, another way of using static hosting is to set the `ssr` property to `false` in the `nuxt.config` file. The `nuxi build` command will then output an `index.html` entrypoint like a classic client-side Vue.js application.

View File

@ -6,6 +6,6 @@ icon: IconCloud
How to deploy Nuxt to [AWS Lambda](https://aws.amazon.com/lambda/)
## Learn more
## Learn More
:ReadMore{link="https://nitro.unjs.io/deploy/providers/aws.html" title="the Nitro documentation for AWS deployment"}

View File

@ -13,6 +13,6 @@ How to deploy to [Azure Static Web Apps](https://azure.microsoft.com/en-us/servi
- Minimal configuration required
::
## Learn more
## Learn More
:ReadMore{link="https://nitro.unjs.io/deploy/providers/azure.html" title="the Nitro documentation for Azure deployment"}

View File

@ -13,6 +13,6 @@ How to deploy Nuxt to [Cloudflare Workers](https://workers.cloudflare.com/).
- Minimal configuration required
::
## Learn more
## Learn More
:ReadMore{link="https://nitro.unjs.io/deploy/providers/cloudflare.html" title="the Nitro documentation for Cloudflare deployment"}

View File

@ -6,6 +6,6 @@ icon: IconCloud
Nitro supports deploying on the [Digital Ocean App Platform](https://docs.digitalocean.com/products/app-platform/) with minimal configuration.
## Learn more
## Learn More
:ReadMore{link="https://nitro.unjs.io/deploy/providers/digitalocean.html" title="the Nitro documentation for DigitalOcean deployment"}

View File

@ -10,6 +10,6 @@ Nitro supports [Firebase Hosting](https://firebase.google.com/docs/hosting) with
**Note**: You need to be on the **Blaze plan** to use Nitro with Cloud Functions.
## Learn more
## Learn More
:ReadMore{link="https://nitro.unjs.io/deploy/providers/firebase.html" title="the Nitro documentation for Firebase deployment"}

View File

@ -6,6 +6,6 @@ icon: IconCloud
How to deploy Nuxt to [Heroku](https://www.heroku.com/).
## Learn more
## Learn More
:ReadMore{link="https://nitro.unjs.io/deploy/providers/heroku.html" title="the Nitro documentation for Heroku deployment"}

View File

@ -8,6 +8,6 @@ Nitro provides a built-in preset to generate output format compatible with [Laye
Layer0 extends the capabilities of a traditional CDN by not only hosting your static content, but also providing server-side rendering for progressive web applications as well as caching both your APIs and HTML at the network edge to provide your users with the fastest browsing experience.
## Learn more
## Learn More
:ReadMore{link="https://nitro.unjs.io/deploy/providers/layer0.html" title="the Nitro documentation for Layer0 deployment"}

View File

@ -6,6 +6,6 @@ icon: IconCloud
How to deploy Nuxt to [Render](https://render.com/)
## Learn more
## Learn More
:ReadMore{link="https://nitro.unjs.io/deploy/providers/render.html" title="the Nitro documentation for Render deployment"}

View File

@ -6,6 +6,6 @@ icon: IconCloud
How to deploy Nuxt to [StormKit](https://www.stormkit.io/).
## Learn more
## Learn More
:ReadMore{link="https://nitro.unjs.io/deploy/providers/stormkit.html" title="the Nitro documentation for StormKit deployment"}

View File

@ -36,6 +36,6 @@ npx nuxi init -t v3-vercel
vercel
```
## Learn more
## Learn More
:ReadMore{link="https://nitro.unjs.io/deploy/providers/vercel.html" title="the Nitro documentation for Vercel deployment"}

View File

@ -2,9 +2,9 @@
Nuxt is a minimal but highly customizable framework to build web applications. This guide helps you better understand Nuxt internals to develop new solutions and module integrations on top of Nuxt.
## The Nuxt interface
## The Nuxt Interface
When you start nuxt in development mode with `nuxi dev` or building a production application with `nuxi build`,
When you start Nuxt in development mode with `nuxi dev` or building a production application with `nuxi build`,
a common context will be created, referred to as `nuxt` internally. It holds normalized options merged with `nuxt.config` file,
some internal state, and a powerful [hooking system](/api/advanced/hooks) powered by [unjs/hookable](https://github.com/unjs/hookable)
allowing different components to communicate with each other. You can think of it as **Builder Core**.
@ -16,13 +16,13 @@ To extend the Nuxt interface and hook into different stages of the build process
For more details, check out [the source code](https://github.com/nuxt/framework/blob/main/packages/nuxt/src/core/nuxt.ts).
## The NuxtApp interface
## The NuxtApp Interface
When rendering a page in the browser or on the server, a shared context will be created, referred to as `nuxtApp`.
This context keeps vue instance, runtime hooks, and internal states like ssrContext and payload for hydration.
You can think of it as **Runtime Core**.
This context can be accessed using `useNuxtApp()` composable within nuxt plugins and `<script setup>` and vue composables.
This context can be accessed using `useNuxtApp()` composable within Nuxt plugins and `<script setup>` and vue composables.
Global usage is possible for the browser but not on the server, to avoid sharing context between users.
To extend the `nuxtApp` interface and hook into different stages or access contexts, we can use [Nuxt Plugins](/guide/directory-structure/plugins).

View File

@ -2,7 +2,7 @@
Nuxt provides a powerful hooking system to expand almost every aspect using hooks powered by [unjs/hookable](https://github.com/unjs/hookable).
## Nuxt Hooks (build time)
## Nuxt Hooks (Build Time)
These hooks are available for [Nuxt Modules](/guide/going-further/modules) and build context.
@ -28,7 +28,7 @@ export default defineNuxtModule({
})
```
## App Hooks (runtime)
## App Hooks (Runtime)
App hooks can be mainly used by [Nuxt Plugins](/guide/directory-structure/plugins) to hook into rendering lifecycle but could also be used in Vue composables.

View File

@ -1,9 +1,9 @@
# Module Author Guide
Nuxt provides a zero-config experience with a preset of integrations and best practices to develop Web applications.
A powerful configuration and hooks system makes it possible to customize almost every aspect of Nuxt Framework and add endless possible integrations when it comes to customization. You can learn more about how nuxt works in the [Nuxt internals](/guide/going-further/internals) section.
A powerful configuration and hooks system makes it possible to customize almost every aspect of Nuxt Framework and add endless possible integrations when it comes to customization. You can learn more about how Nuxt works in the [Nuxt internals](/guide/going-further/internals) section.
Nuxt exposes a powerful API called **Nuxt Modules**. Nuxt modules are simple async functions that sequentially run when starting nuxt in development mode using `nuxi dev` or building a project for production with `nuxi build`.
Nuxt exposes a powerful API called **Nuxt Modules**. Nuxt modules are simple async functions that sequentially run when starting Nuxt in development mode using `nuxi dev` or building a project for production with `nuxi build`.
Using Nuxt Modules, we can encapsulate, properly test and share custom solutions as npm packages without adding unnecessary boilerplate to the Nuxt project itself.
Nuxt Modules can hook into lifecycle events of Nuxt builder, provide runtime app templates, update the configuration or do any other custom action based on needs.
@ -113,7 +113,7 @@ The result of `defineNuxtModule` is a wrapper function with an `(inlineOptions,
::
## Best practices
## Best Practices
### Async Modules
@ -123,7 +123,7 @@ Nuxt Modules can do asynchronous operations. For example, you may want to develo
Be careful that `nuxi dev` waits for your module setup before going to the next module and starting the development server. Do time-consuming logic using deferred Nuxt hooks.
::
### Always prefix exposed interfaces
### Always Prefix Exposed Interfaces
Nuxt Modules should provide an explicit prefix for any exposed configuration, plugin, API, composable, or component to avoid conflict with other modules and internals.
@ -135,7 +135,7 @@ Nuxt 3, has first-class typescript integration for the best developer experience
Exposing types and using typescript to develop modules can benefit users even when not using typescript directly.
### Avoid CommonJS syntax
### Avoid CommonJS Syntax
Nuxt 3, relies on native ESM. Please read [Native ES Modules](/guide/going-further/esm) for more information.
@ -153,16 +153,16 @@ Consider documenting module usage in the readme file:
Linking to the integration website and documentation is always a good idea.
### Use `nuxt-` prefix for npm packages
### Use `nuxt-` Prefix for npm Packages
To make your modules discoverable, use `nuxt-` prefix for the npm package name. This is always the best starting point to draft and try an idea!
### Listing module to modules.nuxtjs.org
### Listing Module on modules.nuxtjs.org
Do you have a working Module and want it listed in [modules.nuxtjs.org](https://modules.nuxtjs.org)? Open an issue in [nuxt/modules](https://github.com/nuxt/modules/issues/new) repository.
Do you have a working Module and want it listed on [modules.nuxtjs.org](https://modules.nuxtjs.org)? Open an issue in [nuxt/modules](https://github.com/nuxt/modules/issues/new) repository.
Nuxt team can help you to apply best practices before listing.
### Do not advertise with a specific Nuxt version
### Do Not Advertize With a Specific Nuxt Version
Nuxt 3, Nuxt Kit, and other new toolings are made to have both forward and backward compatibility in mind.
@ -210,9 +210,9 @@ export default defineNuxtModule({
})
```
### Cleanup Module
### Clean Up Module
If your module opens handles or starts a watcher, we should close it when the nuxt lifecycle is done. For this, we can use the `close` hook:
If your module opens, handles or starts a watcher, you should close it when the Nuxt lifecycle is done. For this, use the `close` hook:
```ts
import { defineNuxtModule } from '@nuxt/kit'

View File

@ -4,9 +4,9 @@
## Usage
### Install dependency
### Install Dependency
You can install the latest nuxt kit by adding it to the `dependencies` section of your `package.json`. However, please consider always explicitly installing the `@nuxt/kit` package even if it is already installed by nuxt.
You can install the latest Nuxt Kit by adding it to the `dependencies` section of your `package.json`. However, please consider always explicitly installing the `@nuxt/kit` package even if it is already installed by Nuxt.
```json [package.json]
{
@ -16,7 +16,7 @@ You can install the latest nuxt kit by adding it to the `dependencies` section o
}
```
### Import kit utilities
### Import Kit Utilities
```js [test.mjs]
import { useNuxt } from '@nuxt/kit'
@ -26,10 +26,10 @@ import { useNuxt } from '@nuxt/kit'
::
::alert{type="warning"}
Nuxt kit utilities are only available for modules and not meant to be imported in runtime (components, vue composables, pages, plugins, or server routes)
Nuxt Kit utilities are only available for modules and not meant to be imported in runtime (components, Vue composables, pages, plugins, or server routes).
::
Nuxt kit, is an [esm-only package](/guide/going-further/esm) meaning you **cannot** `require('@nuxt/kit')`. As a workaround, we can use dynamic import to use it in the CommonJS context:
Nuxt Kit is an [esm-only package](/guide/going-further/esm) meaning that you **cannot** `require('@nuxt/kit')`. As a workaround, use dynamic import in the CommonJS context:
```js [test.cjs]
// This does NOT work!

View File

@ -56,7 +56,7 @@ However, in recent Node.js LTS releases, it is now possible to [use native ESM m
This is what we do for Nuxt Nitro; we output a `.output/server/index.mjs` file. That tells Node.js to treat this file as a native ES module.
### What are valid imports in a Node.js context?
### What Are Valid Imports in a Node.js Context?
When you `import` a module rather than `require` it, Node.js resolves it differently. For example, when you import `sample-library`, Node.js will look not for the `main` but for the `exports` or `module` entry in that library's `package.json`.
@ -68,7 +68,7 @@ Node supports the following kinds of imports (see [docs](https://nodejs.org/api/
1. files ending in `.cjs` - these are expected to use CJS syntax
1. files ending in `.js` - these are expected to use CJS syntax unless their `package.json` has `type: 'module'`
### What kinds of problems can there be?
### What Kinds of Problems Can There Be?
For a long time module authors have been producing ESM-syntax builds but using conventions like `.esm.js` or `.es.js`, which they have added to the `module` field in their `package.json`. This hasn't been a problem until now because they have only been used by bundlers like webpack, which don't especially care about the file extension.
@ -108,11 +108,11 @@ const { named } = pkg;
at async Object.loadESM (internal/process/esm_loader.js:68:5)
```
## Troubleshooting ESM issues
## Troubleshooting ESM Issues
If you encounter these errors, the issue is almost certainly with the upstream library. They need to [fix their library](#library-author-guide) to support being imported by Node.
### Transpiling libraries
### Transpiling Libraries
In the meantime, you can tell Nuxt not to try to import these libraries by adding them to `build.transpile`:
@ -128,7 +128,7 @@ export default defineNuxtConfig({
You may find that you _also_ need to add other packages that are being imported by these libraries.
### Aliasing libraries
### Aliasing Libraries
In some cases, you may also need to manually alias the library to the CJS version, for example:
@ -142,7 +142,7 @@ export default defineNuxtConfig({
})
```
### Default exports
### Default Exports
A dependency with CommonJS format, can use `module.exports` or `exports` to provide a default export:
@ -204,7 +204,7 @@ import myModule from 'my-module'
console.log(interopDefault(myModule)) // { foo: 'bar', baz: 'qux' }
```
## Library author guide
## Library Author Guide
The good news is that it's relatively simple to fix issues of ESM compatibility. There are two main options:
@ -283,7 +283,7 @@ const someFile = await resolvePath('my-lib', { url: import.meta.url })
::
### Best practices
### Best Practices
- Prefer named exports rather than default export. This helps reduce CJS conflicts. (see [Default exports](#default-exports) section)

View File

@ -21,7 +21,7 @@ Plugins also receive `nuxtApp` as the first argument for convenience. [Read more
**`useNuxtApp` (on the server) only works during `setup`, inside Nuxt plugins or `Lifecycle Hooks`**.
::
## Providing helpers
## Providing Helpers
You can provide helpers to be usable across all composables and application. This usually happens within a Nuxt plugin.

View File

@ -35,7 +35,7 @@ Behind the scenes, `setup` performs a number of tasks in `beforeAll`, `beforeEac
## Options
### Nuxt configuration
### Nuxt Configuration
#### `rootDir`
@ -59,7 +59,7 @@ Object with configuration overrides.
* Type: `NuxtConfig`
* Default: `{}` -->
### Setup timings
### Setup Timings
#### `setupTimeout`
@ -68,7 +68,7 @@ The amount of time (in milliseconds) to allow for `setupTest` to complete its wo
* Type: `number`
* Default: `60000`
### Features to enable
### Features to Enable
#### `server`
@ -106,7 +106,7 @@ Specify the runner for the test suite. Currently, [Vitest](https://vitest.dev/)
## APIs
### APIs for rendering testing
### APIs for Rendering Testing
#### `$fetch(url)`
@ -184,7 +184,7 @@ describe('ssr', async () => {
For more usage, please refer to our [tests for Nuxt 3 framework](https://github.com/nuxt/framework/blob/main/test/basic.test.ts).
## Testing in a browser
## Testing in a Browser
::alert{icon=🚧}
We are working on it, stay tuned!

View File

@ -16,7 +16,7 @@ The build and publishing method and quality of edge releases are the same as sta
Features only available on the edge channel are marked with an alert in the documentation.
:::
## Opting into the edge channel
## Opting Into the Edge Channel
Update `nuxt` dependency inside `package.json`:
@ -31,7 +31,7 @@ Update `nuxt` dependency inside `package.json`:
Remove lockfile (`package-lock.json`, `yarn.lock`, or `pnpm-lock.yaml`) and reinstall dependencies.
## Opting out from the edge channel
## Opting Out From the Edge Channel
Update `nuxt` dependency inside `package.json`:
@ -46,7 +46,7 @@ Update `nuxt` dependency inside `package.json`:
Remove lockfile (`package-lock.json`, `yarn.lock`, or `pnpm-lock.yaml`) and reinstall dependencies.
## Using latest `nuxi` CLI from edge
## Using Latest `nuxi` CLI From Edge
:::Alert
All cli dependencies are bundled because of the building method for reducing `nuxi` package size. You can get dependency updates and CLI improvements using the edge channel.

View File

@ -1,5 +1,5 @@
---
title: Going further
title: Going Further
layout.aside: true
layout.asideClass: ''
navigation.redirect: /guide/going-further/tooling

View File

@ -48,7 +48,7 @@ type AsyncData<DataT> = {
Under the hood, `lazy: false` uses `<Suspense>` to block the loading of the route before the data has been fetched. Consider using `lazy: true` and implementing a loading state instead for a snappier user experience.
## Return values
## Return Values
* **data**: the result of the asynchronous function that is passed in
* **pending**: a boolean indicating whether the data is still being fetched

View File

@ -136,7 +136,7 @@ be returned as the cookie's value.
Specifies a function that returns the cookie's default value. The function can also return a `Ref`.
## Handling cookies in API routes
## Handling Cookies in API Routes
You can use `useCookie` and `setCookie` from [`h3`](https://github.com/unjs/h3) package to set cookies in server API routes.

View File

@ -57,7 +57,7 @@ type AsyncData<DataT> = {
If you provide a function or ref as the `url` parameter, or if you provide functions as arguments to the `options` parameter, then the `useFetch` call will not match other `useFetch` calls elsewhere in your codebase, even if the options seem to be identical. If you wish to force a match, you may provide your own key in `options`.
::
## Return values
## Return Values
* **data**: the result of the asynchronous function that is passed in.
* **pending**: a boolean indicating whether the data is still being fetched.

View File

@ -7,14 +7,14 @@ If you have a `pages/` folder, `useRouter` is identical in behavior to the one p
::ReadMore{link="https://router.vuejs.org/api/#currentroute"}
::
## Basic manipulation
## Basic Manipulation
- **addRoute:** Add a new route to the router instance. `parentName` can be provided to add new route as the child of an existing route.
- **removeRoute:** Remove an existing route by its name.
- **getRoutes:** Get a full list of all the route records.
- **hasRoute:** Checks if a route with a given name exists.
## Based on history API
## Based on History API
- **back:** Go back in history if possible, same as `router.go(-1)`.
- **forward:** Go forward in history if possible, same as `router.go(1)`.
@ -36,7 +36,7 @@ router.replace({ hash: "#bio" });
::ReadMore{link="https://developer.mozilla.org/en-US/docs/Web/API/History"}
::
## Navigation guards
## Navigation Guards
`useRouter` composable provides `afterEach`, `beforeEach` and `beforeResolve` helper methods that acts as nagivation guards.
@ -45,7 +45,7 @@ However, Nuxt has a concept of **route middleware** that simplifies the implemen
::ReadMore{link="/guide/directory-structure/middleware"}
::
## Promise and error handling
## Promise and Error Handling
- **isReady:** Returns a Promise that resolves when the router has completed the initial navigation.
- **onError:** Adds an error handler that is called every time a non caught error happens during navigation.
@ -54,7 +54,7 @@ However, Nuxt has a concept of **route middleware** that simplifies the implemen
::ReadMore{link="https://router.vuejs.org/api/#router-methods"}
::
## Universal router instance
## Universal Router Instance
If you do not have a `pages/` folder, then `useRouter` will return a universal router instance with similar helper methods, but be aware that not all features may be supported or behave in exactly the same way as with `vue-router`.

View File

@ -41,7 +41,7 @@ definePageMeta({
:button-link[Open on StackBlitz]{href="https://stackblitz.com/github/nuxt/framework/tree/main/examples/routing/pages?file=app.vue" blank}
## Custom props
## Custom Props
In addition, `NuxtPage` also accepts custom props that you may need to pass further down the hierarchy. These custom props are accessible via `attrs` in the Nuxt app.

View File

@ -43,7 +43,7 @@ Please note the layout name is normalized to kebab-case, so if your layout file
</template>
```
## Layout and transition
## Layout and Transition
`<NuxtLayout />` renders incoming content via `<slot />`, which is then wrapped around Vues `<Transition />` component to activate layout transition. For this to work as expected, it is recommended that `<NuxtLayout />` is **not** the root element of the page component.

View File

@ -9,7 +9,7 @@ Nuxt provides `<NuxtLink>` component to handle any kind of links within your app
## Examples
### Basic usage
### Basic Usage
In this example, we use `<NuxtLink>` component to link to a website.
@ -24,7 +24,7 @@ In this example, we use `<NuxtLink>` component to link to a website.
:button-link[Open on StackBlitz]{href="https://stackblitz.com/github/nuxt/framework/tree/main/examples/routing/nuxt-link?terminal=dev&file=/pages/index.vue" blank}
### Internal routing
### Internal Routing
In this example, we use `<NuxtLink>` component to link to another page of the application.
@ -39,7 +39,7 @@ In this example, we use `<NuxtLink>` component to link to another page of the ap
:button-link[Open on StackBlitz]{href="https://stackblitz.com/github/nuxt/framework/tree/main/examples/routing/nuxt-link?terminal=dev&file=/pages/index.vue" blank}
### `target` and `rel` attributes
### `target` and `rel` Attributes
In this example, we use `<NuxtLink>` with `target`, `rel`, and `noRel` props.
@ -87,7 +87,7 @@ In this example, we use `<NuxtLink>` with `target`, `rel`, and `noRel` props.
Defaults can be overwritten, see [overwriting defaults](#overwriting-defaults) if you want to change them.
::
## Overwriting defaults
## Overwriting Defaults
You can overwrite `<NuxtLink>` defaults by creating your own link component using `defineNuxtLink`.
@ -102,7 +102,7 @@ You can then use `<MyNuxtLink />` component as usual with your new defaults.
:button-link[Open on StackBlitz]{href="https://stackblitz.com/github/nuxt/framework/tree/main/examples/routing/nuxt-link?terminal=dev&file=/components/MyNuxtLink.ts" blank}
### `defineNuxtLink` signature
### `defineNuxtLink` Signature
```ts
defineNuxtLink({

View File

@ -7,7 +7,7 @@ Nuxt provides `<NuxtLoadingIndicator>` to display a progress bar on page navigat
## Examples
### Basic usage
### Basic Usage
Add `<NuxtLoadingIndicator/>` in your `app.vue` or layouts.

View File

@ -6,7 +6,7 @@ You can use this function to create an error object with additional metadata. It
* err: { cause, data, message, name, stack, statusCode, statusMessage, fatal }
## Throwing errors in your Vue app
## Throwing Errors in Your Vue App
If you throw an error created with `createError`:
@ -25,7 +25,7 @@ if (!data.value) {
</script>
```
## Throwing errors in API routes
## Throwing Errors in API Routes
You can use `createError` to trigger error handling in server API routes.

View File

@ -18,7 +18,7 @@ Make sure to use always `await` or `return` on result of `navigateTo()` when cal
## Examples
### Within a Vue component
### Within a Vue Component
```vue
<script setup>
@ -39,7 +39,7 @@ return navigateTo({
</script>
```
### Within route middleware
### Within Route Middleware
```js
export default defineNuxtRouteMiddleware((to, from) => {

View File

@ -11,7 +11,7 @@
- `installModule(module, inlineOptions)`
### Programmatic usage
### Programmatic Usage
[source code](https://github.com/nuxt/framework/blob/main/packages/kit/src/loader)

View File

@ -4,7 +4,7 @@
npx nuxi clean|cleanup [rootDir]
```
The `cleanup` command, removes common generated nuxt files and caches. Including:
The `cleanup` command removes common generated Nuxt files and caches, including:
- `.nuxt`
- `.output`

View File

@ -2,7 +2,7 @@
template: Example
---
# Hello world
# Hello World
A minimal Nuxt 3 application only requires the `app.vue` and `nuxt.config.js` files.

View File

@ -2,7 +2,7 @@
template: Example
---
# Config extends
# 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.

View File

@ -2,7 +2,7 @@
template: Example
---
# Module Extend pages
# Module Extend Pages
This example defines a new `test` page using `extendPages` within a module.

View File

@ -2,7 +2,7 @@
At some point, you may find that there's an issue you need some help with. But don't worry! We're a friendly community of developers and we'd love to help.
## "I can't figure out how to __."
## "I can't figure out how to (...)."
You've read through these docs and you think it should be possible, but it's not clear how. The best thing is to [open a GitHub Discussion](https://github.com/nuxt/framework/discussions).

View File

@ -4,15 +4,15 @@ Try as we might, we will never completely eliminate bugs. One of the most valuab
Here are a few key steps.
## Is it really a bug?
## Is It Really a Bug?
Consider if you're looking to get help with something, or whether you think there's a bug with Nuxt itself. If it's the former, we'd love to help you - but the best way to do that is through [asking for help](/community/getting-help) rather than reporting a bug.
## Search the issues
## Search the Issues
Search through the [open issues](https://github.com/nuxt/framework/issues) and [discussions](https://github.com/nuxt/framework/discussions) first. If you find anything that seems like the same bug, it's much better to comment on an existing thread than create a duplicate.
## Create a minimal reproduction
## Create a Minimal Reproduction
It's important to be able to reproduce the bug reliably - in a minimal way and apart from the rest of your project. This narrows down what could be causing the issue and makes it possible for someone not only to find the cause, but also to test a potential solution.
@ -38,6 +38,6 @@ If your issue concerns Vue 3 or Vite, please try to reproduce it first with the
Once you've reproduced the issue, remove as much code from your reproduction as you can (while still recreating the bug). The time spent making the reproduction as minimal as possible will make a huge difference to whoever sets out to fix the issue.
## Figure out what the cause might be
## Figure Out What the Cause Might Be
With a Nuxt project, there are lots of moving pieces - from [nuxt modules](https://nuxtjs.org/modules) to [other JavaScript libraries](https://www.npmjs.com/). Try to report the bug at the most relevant and specific place. That will likely be the Nuxt module causing an issue, or the upstream library that Nuxt is depending on.

View File

@ -13,13 +13,13 @@ The Nuxt ecosystem includes many different projects and organizations. For examp
* [nuxt-contrib/](https://github.com/nuxt-contrib) - the previous home for libraries that are not specific to Nuxt but produced and used by the Nuxt team.
* [unjs/](https://github.com/unjs) - many of these libraries are used throughout the Nuxt ecosystem. They are designed to be universal libraries that are framework- and environment-agnostic. We welcome contributions and usage by other frameworks and projects.
## How to contribute
## How To Contribute
### Triage issues and help out in discussions
### Triage Issues and Help Out in Discussions
Check out the issues and discussions for the project you want to help. For example, here are [the issues board](https://github.com/nuxt/framework/issues) and [discussions](https://github.com/nuxt/framework/discussions) for Nuxt 3. Helping other users, sharing workarounds, creating reproductions, or even poking into a bug a little bit and sharing your findings makes a huge difference.
### Creating an issue
### Creating an Issue
Thank you for taking the time to create an issue! ❤️
@ -29,11 +29,11 @@ Thank you for taking the time to create an issue! ❤️
We'll do our best to follow our [internal issue decision making flowchart](https://kroki.io/mermaid/svg/eNp9Uktv2kAQvudXzM32IZEK5GJFqUgIhYagqOqlx7V3bLasd1f7SIKg_72ztrFpDuVgiZ35HvPNVFK_lztmPfxcXAH95sellvSIHIRzAcFjYyTz-PVPV7--vj_9QneCh-PaAQ9GivJTeatP8Jg-Su0QmOLA3B68hqolHgizqxbxMBA-XUCMFspH0CCQjd2Rf3FcMQeNUKJhEiwaq3kovdCKnLSti4F4GZ2y0gcm5QEYFKHu7S7OdN_SDStQ5pAoRO7-IUzuCnvfiHrnoWwNigqUhmA42YI7mAJnB9ePsxxUV-mXG_iBjX5DSAwqLlQN3gpWYwIyqkXeyQ3MOYeEPF28TrtXizEoSoOVe4J19SjPTJtKITF2z7puY4W2wh-6tmy0Ewdcxwz8DqHAHXujRqCAyRTyc17rwfn39OmDViRUu4p25igz7kSXrg2BokKejego9Jw-IxrQNDFt3AIXrgzOUY6Rw_4vj-5YYhojKOlzXRH_5rjQ-GmKhu0RtuHDQ1DBxUT61W6GcV4uYKEGVlVY-vZvw353iekKgkPrLrFxmO1xbjG20vdd2z2zOig6jzhYz3eO72XQe71NzW0OwdaofDYWI-HrLDWzHERjtPXsXN6O2ElqJjns6LZHvYumlmOammkeb59ckIPsL5zkNv8) when responding to issues.
### Send a pull request
### Send a Pull Request
We always welcome pull requests! ❤️
#### Before you start
#### Before You Start
Before you fix a bug, we recommend that you check whether **there's an issue that describes it**, as it's possible it's a documentation issue or that there is some context that would be helpful to know.
@ -43,7 +43,7 @@ For typo fixes, it's recommended to batch multiple typo fixes into one pull requ
For bigger changes to Nuxt itself, we recommend that you first [create a Nuxt module](#create-a-module) and implement the feature there. This allows for quick proof-of-concept. You can then [create an RFC](#make-an-rfc) in the form of a discussion. As users adopt it and you gather feedback, it can then be refined and either added to Nuxt core or continue as a standalone module.
#### Commit conventions
#### Commit Conventions
We use [Conventional Commits](https://www.conventionalcommits.org/) for commit messages, which [allows a changelog to be auto-generated](https://github.com/unjs/changelogen) based on the commits. Please read the guide through if you aren't familiar with it already.
@ -53,7 +53,7 @@ Note that `fix:` and `feat:` are for **actual code changes** (that might affect
If you are working in a project with a monorepo, like `nuxt/framework`, ensure that you specify the main scope of your commit in brackets. For example: `feat(nuxi): add 'do-magic' command`.
#### Making the pull request
#### Making the Pull Request
If you don't know how to send a pull request, we recommend reading [the guide](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request).
@ -67,7 +67,7 @@ We do not add any commit hooks to allow for quick commits. But before you make a
In general, please also make sure that there are no _unrelated_ changes in a PR. For example, if your editor has made any changes to whitespace or formatting elsewhere in a file that you edited, please revert these so it is more obvious what your PR changes. And please avoid including multiple unrelated features or fixes in a single PR. If it is possible to separate them, it is better to have multiple PRs to review and merge separately. In general, a PR should do _one thing only_.
#### Once you've made a pull request
#### Once You've Made a Pull Request
Once you've made a pull request, we'll do our best to review it promptly.
@ -79,7 +79,7 @@ If we mark a PR as 'pending', that means we likely have another task to do in re
We'll do our best to follow [our PR decision making flowchart](https://kroki.io/mermaid/svg/eNqFk89vm1AMx-_9K3wrqZYcdpymRk3SdJ22qYqmVTuahwGrD0zfj6So7H-fHyTNehoHBH7G34-_NqWVg6nRBfi5uQC9bl4fawzwxG0BUsLDDtgDh-Wf6XQ-nw-rWEHJLwOsXu_TGSBc-uDYhBS-_Jy7a17QIr2QB2xB8j1L9CB7cp6rOqSUA4caWgHPBQGVJZng_1XZEoboaIB1dgUb9iZ6D-UUhJYMec-hT5WuQDFCzelGkJMPcMAeggAWhdO8Md4SFcspfUd7pgMYUeXniPatzk1RvElYzMn6Y7zrnMIDl9BL1BSyoB1LW1nVSX4lhdOXCpLEqFjMzu1sxMSG2oCBpR1gk50xLDolUKMKQGOiQ3PE-SbyBKU4kK4TF2LLgdVRbYybCchiW0WsaDafX9-PYmt9us1uDqhz4baLOhMnDTyI9DhljWmrxPSb_ABbJflFjst-aoJfwIpBa_v_mLWj58jabkiGG_SjPdh1lg3mls5J43mtpMquKdPs0PWzM8kPGeAuO005cXQS1C1G-25B0koeKT8ALarFp0lmLdEWMLasYymioWSRkmgopxp1_9yZQTdSi7gR2h93YiPk3xcIItBg25--W068d2rilyxtSue0aprctCrJ3dvJ3W0yOjtuTYp_zb6Tq04OpWgBeQ8fQbEaGU3EBhpqcv1DJp2Lvz5hNKI) when responding and reviewing to pull requests.
### Create a module
### Create a Module
If you've built something with Nuxt that's cool, why not [extract it into a module](/guide/going-further/modules), so it can be shared with others? We have [many excellent modules already](https://modules.nuxtjs.org/), but there's always room for more.
@ -101,15 +101,15 @@ An RFC will then move through the following stages:
* `rfc: shipped` - implemented
* `rfc: archived` - not approved, but archived for future reference
### Conventions across ecosystem
### Conventions Across Ecosystem
The following conventions are _required_ within the `nuxt/` organization and recommended for other maintainers in the ecosystem.
#### Module conventions
#### Module Conventions
Modules should follow the [Nuxt module template](https://github.com/nuxt/starter/tree/module). See [module guide](/guide/going-further/modules) for more information.
#### Use core `unjs/` libraries
#### Use Core `unjs/` Libraries
We recommend the following libraries which are used throughout the ecosystem:
@ -118,7 +118,7 @@ We recommend the following libraries which are used throughout the ecosystem:
* [unbuild](https://github.com/unjs/unbuild) - rollup-powered build system
* ... check out the rest of the [unjs/](https://github.com/unjs) organization for many more!
#### Use ESM syntax and default to `type: module`
#### Use ESM Syntax and Default to `type: module`
Most of the Nuxt ecosystem can consume ESM directly. In general we advocate that you avoid using CJS-specific code, such as `__dirname` and `require` statements. You can [read more about ESM](/concepts/esm).
@ -159,7 +159,7 @@ If you have Prettier installed in your editor, we recommend you disable it when
**Note**: [we are discussing](https://github.com/nuxt/eslint-config/issues/224) enabling prettier in future.
#### Package manager
#### Package Manager
For libraries, we recommend `pnpm`. For modules, we still recommend `yarn` but we may well switch this recommendation to `pnpm` in future once we support plug and play mode with Nuxt itself.
@ -173,7 +173,7 @@ corepack enable
You only need to do this one time, after Node.js is installed on your computer.
## Writing documentation
## Writing Documentation
Documentation is an essential part of Nuxt. We aim to be an intuitive framework - and a big part of that is making sure that both the developer experience and the docs are perfect across the ecosystem. 👌

View File

@ -2,7 +2,7 @@
Once you've read the [general contribution guide](./contribution), here are some specific points to make about contributions to the `nuxt/framework` repository.
## Using the playground
## Using the Playground
While working on a PR, you will likely want to check if your changes are working correctly.
@ -22,7 +22,7 @@ You might have noticed already that we use ESLint to enforce a coding standard.
If you are adding a new feature or refactoring or changing the behavior of Nuxt in any other manner, you'll likely want to document the changes. Please include any changes to the docs in the same PR. You don't have to write documentation up on the first commit (but please do so as soon as your pull request is mature enough). Make sure to make changes according to the [Documentation Guide](./contribution#documentation-guide).
### Final checklist
### Final Checklist
When submitting your PR, there is a simple template that you have to fill out. Please tick all appropriate "answers" in the checklists.
@ -40,20 +40,20 @@ Make the change directly in the GitHub interface and open a Pull Request.
The documentation content is inside the `docs/` directory of the [nuxt/framework repository](https://github.com/nuxt/framework) and written in markdown.
To contribute, fork the repository and follow [these steps](#setup-documentation-website-in-local-environment) and start docs in development mode.
To contribute, fork the repository and follow [these steps](#set-up-documentation-website-in-local-environment) and start docs in development mode.
After making your changes:
- Lint the documentation with the `lint:docs` command.
- Open a Pull Request. Please make sure your PR title adheres to the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) guidelines.
### Linting docs
### Linting Docs
Documentation is linted using [MarkdownLint](https://github.com/DavidAnson/markdownlint/) and [case police](https://github.com/antfu/case-police) to keep the documentation cohesive.
## Set up your local development environment
## Set Up Your Local Development Environment
To contribute to Nuxt, you need to setup a local environment.
To contribute to Nuxt, you need to set up a local environment.
1. [Fork](https://help.github.com/articles/fork-a-repo/) the [nuxt/framework repository](https://github.com/nuxt/framework) to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device.
@ -79,9 +79,9 @@ git checkout -b my-new-branch
::doc-link{file=packages/nuxt/src/test.js function=useState}
::
### Setup documentation website in local environment
### Set Up Documentation Website in Local Environment
1. Follow steps to setup [local development environment](#set-up-your-local-development-environment)
1. Follow steps to set up [local development environment](#set-up-your-local-development-environment)
1. Change to the `docs/` directory using `cd docs/`
1. Install docs dependencies using `yarn install`
1. Start docs in development mode using `yarn dev`

View File

@ -14,7 +14,7 @@ Nuxt is constantly evolving, with new features and modules being added all the t
- [Rendering Optimizations: Today and Tomorrow](https://github.com/nuxt/framework/discussions/5856)
- [Nuxt Image: Performance and Status](https://github.com/nuxt/image/discussions/563)
## 📅 Release schedule
## 📅 Release Schedule
Release | Expected date | Description
--------------------|-----------------|---------------------------------------------------

View File

@ -63,7 +63,7 @@ npm install -D @nuxt/bridge@npm:@nuxt/bridge-edge
::
## Update your scripts
## Update Your Scripts
You will also need to update your scripts within your `package.json` to reflect the fact that Nuxt will now produce a Nitro server as build output.
@ -84,7 +84,7 @@ Nuxt 3 introduced the new Nuxt CLI command [`nuxi`](/api/commands/add). Update y
}
```
### Static target
### Static Target
If you have set `target: 'static'` in your `nuxt.config` then you need to ensure that you update your build script to be `nuxi generate`.
@ -96,7 +96,7 @@ If you have set `target: 'static'` in your `nuxt.config` then you need to ensure
}
```
### Server target
### Server Target
For all other situations, you can use the `nuxi build` command.
@ -157,7 +157,7 @@ If you were using `@vue/composition-api` or `@nuxtjs/composition-api`, please re
Nuxt 3 natively supports TypeScript and ECMAScript Modules. Please check [Native ES Modules](/guide/going-further/esm) for more info and upgrading.
## Remove incompatible and obsolete modules
## Remove Incompatible and Obsolete Modules
- Remove `@nuxt/content` (1.x). A rewrite for Nuxt 3 is planned (2.x)
- Remove `nuxt-vite`: Bridge enables same functionality
@ -167,11 +167,11 @@ Nuxt 3 natively supports TypeScript and ECMAScript Modules. Please check [Native
- Remove `@vue/composition-api` from your dependencies ([migration guide](/bridge/bridge-composition-api)).
- Remove `@nuxtjs/composition-api` from your dependencies (and from your modules in `nuxt.config`) ([migration guide](/bridge/bridge-composition-api)).
## Exclude built Nitro folder from git
## Exclude Built Nitro Folder From Git
Add the folder `.output` to the `.gitignore` file.
## Ensure everything goes well
## Ensure Everything Goes Well
✔️ Try with `nuxi dev` and `nuxi build` (or `nuxi generate`) to see if everything goes well.
@ -185,7 +185,7 @@ export default defineNuxtConfig({
})
```
## New plugins format (optional)
## New Plugins Format (Optional)
You can now migrate to the Nuxt 3 plugins API, which is slightly different in format from Nuxt 2.
@ -206,7 +206,7 @@ If you want to use the new Nuxt composables (such as `useNuxtApp` or `useRuntime
Although a compatibility interface is provided via `nuxtApp.vueApp` you should avoid registering plugins, directives, mixins or components this way without adding your own logic to ensure they are not installed more than once, or this may cause a memory leak.
::
## New `useHead` (optional)
## New `useHead` (Optional)
Nuxt Bridge provides a new Nuxt 3 meta API that can be accessed with a new `useHead` composable.
@ -260,7 +260,7 @@ export default defineNuxtConfig({
// Use legacy server instead of Nitro
// nitro: false,
// Disable nuxt 3 compatible `nuxtApp` interface
// Disable Nuxt 3 compatible `nuxtApp` interface
// app: false,
// Disable Composition API support

View File

@ -114,7 +114,7 @@ Nuxt can type-check your app using [`vue-tsc`](https://github.com/johnsoncodehk/
1. Run `npx nuxi prepare` to generate `.nuxt/tsconfig.json`.
1. Install Volar following the instructions in the [docs](/getting-started/quick-start#prerequisites).
## Vue changes
## Vue Changes
There are a number of changes to what is recommended Vue best practice, as well as a number of breaking changes between Vue 2 and 3.

View File

@ -39,7 +39,7 @@ If you have a fixture or example in your module, add `@nuxt/bridge` package to i
Nuxt 3 natively supports TypeScript and ECMAScript Modules. Please check [Native ES Modules](/guide/going-further/esm) for more info and upgrading.
### Ensure plugins default export
### 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.
@ -65,13 +65,13 @@ export default () => { }
::
### Avoid runtime modules
### 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`](/guide/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`](/guide/directory-structure/nuxt.config#publicruntimeconfig) instead.
- Avoid updating `process.env` within a Nuxt module and reading by a Nuxt plugin; use [`runtimeConfig`](/guide/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
@ -81,7 +81,7 @@ Your module should work even if it's only added to [`buildModules`](/guide/direc
Continue reading about Nuxt 3 modules in the [Modules guide](/guide/going-further/modules).
::
### Use TypeScript (optional)
### 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.

View File

@ -67,7 +67,7 @@ useHead({
::
### Example: built-in meta-components
### 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.

View File

@ -42,7 +42,7 @@ You can read more about the format of `nuxtApp` in [the docs](/api/composables/u
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
Route middleware has a different format.

View File

@ -61,24 +61,24 @@ You will also need to change how you define the layout used by a page using the
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
### 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
### Nested Routes
In Nuxt 2, you will have defined any nested routes (with parent and child components) using `<Nuxt>` and `<NuxtChild>`. In Nuxt 3, these have been replaced with a single `<NuxtPage>` component.
### Page keys and keep-alive props
### Page Keys and Keep-alive Props
If you were passing a custom page key or keep-alive props to `<Nuxt>`, you will now use `definePageMeta` to set these options.
See [more about migrating Nuxt component hooks](/migration/nuxt-hooks).
### Page and layout transitions
### 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.
@ -130,7 +130,7 @@ If you have been defining transitions for your page or layout directly in your c
::
#### Example: Nested routes and `definePageMeta`
#### Example: Nested Routes and `definePageMeta`
::code-group
@ -172,7 +172,7 @@ definePageMeta({
::
## NuxtLink component
## `<NuxtLink>` Component
Most of the syntax and functionality are the same for the global [NuxtLink](/api/components/nuxt-link) component. If you have been using the shortcut `<NLink>` format, you should update this to use `<NuxtLink>`.

View File

@ -5,14 +5,14 @@ head.titleTemplate: ''
# Component Options
## `asyncData` and `fetch` component options
## `asyncData` and `fetch` Component Options
Nuxt 3 provides new options for [fetching data from an API](/guide/features/data-fetching).
<!-- TODO: Intro to <script setup> -->
<!-- TODO: Mention about options compatibility with asyncData -->
### Isomorphic fetch
### Isomorphic Fetch
In Nuxt 2 you might use `@nuxtjs/axios` or `@nuxt/http` to fetch your data - or just the polyfilled global `fetch`.
@ -24,7 +24,7 @@ In Nuxt 3 you can use a globally available `fetch` method that has the same API
You can read more [about direct API calls](/guide/concepts/server-engine#direct-api-calls) or [fetching data](/guide/features/data-fetching).
### Using composables
### 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.

View File

@ -1,9 +1,9 @@
---
title: Nuxt Config
head.title: Nuxt configuration reference
head.title: Nuxt Configuration Reference
---
# Nuxt configuration reference
# Nuxt Configuration Reference
::AutoGenerated
::