@nuxt/docs 4.2.1 → 4.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/1.getting-started/01.introduction.md +1 -1
- package/1.getting-started/03.configuration.md +27 -27
- package/1.getting-started/04.views.md +5 -5
- package/1.getting-started/05.assets.md +7 -7
- package/1.getting-started/06.styling.md +5 -5
- package/1.getting-started/07.routing.md +7 -7
- package/1.getting-started/08.seo-meta.md +3 -3
- package/1.getting-started/09.transitions.md +6 -6
- package/1.getting-started/10.data-fetching.md +2 -2
- package/1.getting-started/11.state-management.md +2 -2
- package/1.getting-started/12.error-handling.md +3 -3
- package/1.getting-started/13.server.md +2 -2
- package/1.getting-started/14.layers.md +3 -3
- package/1.getting-started/16.deployment.md +1 -1
- package/1.getting-started/17.testing.md +32 -1
- package/1.getting-started/18.upgrade.md +23 -23
- package/{2.guide/1.directory-structure → 2.directory-structure}/0.nuxt.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/0.output.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.assets.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.components.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.composables.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.layouts.md +3 -3
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.middleware.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.pages.md +7 -7
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.plugins.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/1.utils.md +3 -3
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/3.app.md +4 -4
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/3.error.md +1 -3
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.content.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.modules.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.node_modules.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.server.md +3 -3
- package/{2.guide/1.directory-structure → 2.directory-structure}/1.shared.md +3 -3
- package/{2.guide/1.directory-structure → 2.directory-structure}/2.env.md +2 -2
- package/{2.guide/1.directory-structure → 2.directory-structure}/2.nuxtignore.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/2.nuxtrc.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/3.nuxt-config.md +1 -1
- package/{2.guide/1.directory-structure → 2.directory-structure}/3.package.md +1 -1
- package/2.directory-structure/index.md +61 -0
- package/{2.guide → 3.guide}/0.index.md +4 -7
- package/{2.guide/2.concepts/3.rendering.md → 3.guide/1.concepts/1.rendering.md} +1 -27
- package/{2.guide/2.concepts/2.vuejs-development.md → 3.guide/1.concepts/10.vuejs-development.md} +4 -3
- package/{2.guide/2.concepts/10.nuxt-lifecycle.md → 3.guide/1.concepts/2.nuxt-lifecycle.md} +32 -25
- package/{2.guide/2.concepts/1.auto-imports.md → 3.guide/1.concepts/3.auto-imports.md} +5 -5
- package/{2.guide/2.concepts → 3.guide/1.concepts}/4.server-engine.md +3 -3
- package/{2.guide/2.concepts → 3.guide/1.concepts}/5.modules.md +1 -1
- package/{2.guide/2.concepts → 3.guide/1.concepts}/7.esm.md +1 -0
- package/{2.guide/2.concepts → 3.guide/1.concepts}/8.typescript.md +4 -4
- package/{2.guide/5.best-practices → 3.guide/2.best-practices}/performance.md +2 -2
- package/3.guide/3.ai/.navigation.yml +3 -0
- package/3.guide/3.ai/1.mcp.md +255 -0
- package/3.guide/3.ai/2.llms-txt.md +65 -0
- package/{2.guide → 3.guide}/4.recipes/1.custom-routing.md +1 -1
- package/{2.guide → 3.guide}/4.recipes/2.vite-plugin.md +1 -1
- package/{2.guide → 3.guide}/4.recipes/3.custom-usefetch.md +1 -1
- package/{2.guide → 3.guide}/4.recipes/4.sessions-and-authentication.md +1 -1
- package/{2.guide/3.going-further → 3.guide/5.going-further}/1.events.md +2 -3
- package/{2.guide/3.going-further → 3.guide/5.going-further}/1.experimental-features.md +4 -4
- package/{2.guide/3.going-further → 3.guide/5.going-further}/1.internals.md +3 -2
- package/{2.guide/3.going-further → 3.guide/5.going-further}/10.runtime-config.md +2 -2
- package/{2.guide/3.going-further → 3.guide/5.going-further}/2.hooks.md +2 -2
- package/{2.guide/3.going-further → 3.guide/5.going-further}/3.modules.md +2 -2
- package/{2.guide/3.going-further → 3.guide/5.going-further}/6.nuxt-app.md +3 -3
- package/{2.guide/3.going-further → 3.guide/5.going-further}/7.layers.md +12 -12
- package/{3.api → 4.api}/1.components/12.nuxt-route-announcer.md +1 -3
- package/{3.api → 4.api}/1.components/13.nuxt-time.md +0 -2
- package/{3.api → 4.api}/1.components/2.nuxt-page.md +2 -2
- package/{3.api → 4.api}/1.components/3.nuxt-layout.md +5 -5
- package/{3.api → 4.api}/1.components/5.nuxt-loading-indicator.md +1 -1
- package/{3.api → 4.api}/1.components/7.nuxt-welcome.md +2 -2
- package/{3.api → 4.api}/2.composables/use-app-config.md +1 -1
- package/4.api/2.composables/use-cookie.md +183 -0
- package/{3.api → 4.api}/2.composables/use-fetch.md +31 -31
- package/{3.api → 4.api}/2.composables/use-lazy-fetch.md +8 -8
- package/{3.api → 4.api}/2.composables/use-nuxt-app.md +4 -4
- package/{3.api → 4.api}/2.composables/use-response-header.md +1 -1
- package/{3.api → 4.api}/2.composables/use-route-announcer.md +0 -2
- package/{3.api → 4.api}/2.composables/use-route.md +1 -1
- package/{3.api → 4.api}/2.composables/use-router.md +2 -2
- package/{3.api → 4.api}/2.composables/use-runtime-config.md +1 -1
- package/{3.api → 4.api}/3.utils/$fetch.md +1 -1
- package/{3.api → 4.api}/3.utils/abort-navigation.md +1 -1
- package/{3.api → 4.api}/3.utils/add-route-middleware.md +1 -1
- package/{3.api → 4.api}/3.utils/call-once.md +0 -2
- package/{3.api → 4.api}/3.utils/define-nuxt-plugin.md +12 -12
- package/{3.api → 4.api}/3.utils/define-nuxt-route-middleware.md +1 -1
- package/{3.api → 4.api}/3.utils/define-page-meta.md +6 -6
- package/{3.api → 4.api}/3.utils/navigate-to.md +10 -10
- package/{3.api → 4.api}/3.utils/refresh-cookie.md +0 -2
- package/{3.api → 4.api}/3.utils/update-app-config.md +2 -2
- package/{3.api → 4.api}/4.commands/add.md +10 -10
- package/4.api/4.commands/analyze.md +42 -0
- package/4.api/4.commands/build-module.md +42 -0
- package/4.api/4.commands/build.md +47 -0
- package/{3.api → 4.api}/4.commands/cleanup.md +6 -6
- package/4.api/4.commands/dev.md +60 -0
- package/{3.api → 4.api}/4.commands/devtools.md +7 -7
- package/4.api/4.commands/generate.md +42 -0
- package/4.api/4.commands/info.md +33 -0
- package/4.api/4.commands/init.md +50 -0
- package/4.api/4.commands/module.md +84 -0
- package/4.api/4.commands/prepare.md +41 -0
- package/4.api/4.commands/preview.md +44 -0
- package/4.api/4.commands/test.md +40 -0
- package/4.api/4.commands/typecheck.md +44 -0
- package/4.api/4.commands/upgrade.md +37 -0
- package/{3.api → 4.api}/5.kit/1.modules.md +16 -16
- package/{3.api → 4.api}/5.kit/10.templates.md +23 -23
- package/{3.api → 4.api}/5.kit/11.nitro.md +35 -35
- package/{3.api → 4.api}/5.kit/14.builder.md +15 -15
- package/{3.api → 4.api}/5.kit/16.layers.md +12 -12
- package/{3.api → 4.api}/5.kit/2.programmatic.md +2 -2
- package/{3.api → 4.api}/5.kit/4.autoimports.md +18 -18
- package/4.api/5.kit/5.components.md +146 -0
- package/4.api/6.advanced/1.hooks.md +105 -0
- package/{3.api → 4.api}/6.nuxt-config.md +5 -4
- package/5.community/6.roadmap.md +25 -25
- package/5.community/7.changelog.md +10 -0
- package/6.bridge/1.overview.md +1 -1
- package/6.bridge/2.typescript.md +1 -1
- package/6.bridge/3.bridge-composition-api.md +1 -1
- package/6.bridge/4.plugins-and-middleware.md +2 -2
- package/7.migration/11.server.md +1 -1
- package/7.migration/2.configuration.md +2 -2
- package/7.migration/20.module-authors.md +1 -1
- package/7.migration/3.auto-imports.md +1 -1
- package/7.migration/5.plugins-and-middleware.md +2 -2
- package/7.migration/6.pages-and-layouts.md +6 -6
- package/package.json +1 -1
- package/3.api/2.composables/use-cookie.md +0 -183
- package/3.api/4.commands/analyze.md +0 -42
- package/3.api/4.commands/build-module.md +0 -42
- package/3.api/4.commands/build.md +0 -47
- package/3.api/4.commands/dev.md +0 -60
- package/3.api/4.commands/generate.md +0 -42
- package/3.api/4.commands/info.md +0 -33
- package/3.api/4.commands/init.md +0 -50
- package/3.api/4.commands/module.md +0 -84
- package/3.api/4.commands/prepare.md +0 -41
- package/3.api/4.commands/preview.md +0 -44
- package/3.api/4.commands/test.md +0 -40
- package/3.api/4.commands/typecheck.md +0 -44
- package/3.api/4.commands/upgrade.md +0 -37
- package/3.api/5.kit/5.components.md +0 -146
- package/3.api/6.advanced/1.hooks.md +0 -105
- /package/{2.guide/1.directory-structure → 2.directory-structure}/.navigation.yml +0 -0
- /package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/.navigation.yml +0 -0
- /package/{2.guide/1.directory-structure → 2.directory-structure}/1.app/3.app-config.md +0 -0
- /package/{2.guide/1.directory-structure → 2.directory-structure}/1.public.md +0 -0
- /package/{2.guide/1.directory-structure → 2.directory-structure}/2.gitignore.md +0 -0
- /package/{2.guide/1.directory-structure → 2.directory-structure}/3.tsconfig.md +0 -0
- /package/{2.guide → 3.guide}/.navigation.yml +0 -0
- /package/{2.guide/2.concepts → 3.guide/1.concepts}/.navigation.yml +0 -0
- /package/{2.guide/2.concepts → 3.guide/1.concepts}/9.code-style.md +0 -0
- /package/{2.guide/5.best-practices → 3.guide/2.best-practices}/.navigation.yml +0 -0
- /package/{2.guide/5.best-practices → 3.guide/2.best-practices}/hydration.md +0 -0
- /package/{2.guide/5.best-practices → 3.guide/2.best-practices}/plugins.md +0 -0
- /package/{2.guide → 3.guide}/4.recipes/.navigation.yml +0 -0
- /package/{2.guide/3.going-further → 3.guide/5.going-further}/.navigation.yml +0 -0
- /package/{2.guide/3.going-further → 3.guide/5.going-further}/1.features.md +0 -0
- /package/{2.guide/3.going-further → 3.guide/5.going-further}/11.nightly-release-channel.md +0 -0
- /package/{2.guide/3.going-further → 3.guide/5.going-further}/4.kit.md +0 -0
- /package/{2.guide/3.going-further → 3.guide/5.going-further}/9.debugging.md +0 -0
- /package/{2.guide/3.going-further → 3.guide/5.going-further}/index.md +0 -0
- /package/{3.api → 4.api}/.navigation.yml +0 -0
- /package/{3.api → 4.api}/1.components/.navigation.yml +0 -0
- /package/{3.api → 4.api}/1.components/1.client-only.md +0 -0
- /package/{3.api → 4.api}/1.components/1.dev-only.md +0 -0
- /package/{3.api → 4.api}/1.components/1.nuxt-client-fallback.md +0 -0
- /package/{3.api → 4.api}/1.components/10.nuxt-picture.md +0 -0
- /package/{3.api → 4.api}/1.components/11.teleports.md +0 -0
- /package/{3.api → 4.api}/1.components/4.nuxt-link.md +0 -0
- /package/{3.api → 4.api}/1.components/6.nuxt-error-boundary.md +0 -0
- /package/{3.api → 4.api}/1.components/8.nuxt-island.md +0 -0
- /package/{3.api → 4.api}/1.components/9.nuxt-img.md +0 -0
- /package/{3.api → 4.api}/2.composables/.navigation.yml +0 -0
- /package/{3.api → 4.api}/2.composables/on-prehydrate.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-async-data.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-error.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-head-safe.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-head.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-hydration.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-lazy-async-data.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-loading-indicator.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-nuxt-data.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-preview-mode.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-request-event.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-request-fetch.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-request-header.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-request-headers.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-request-url.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-runtime-hook.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-seo-meta.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-server-seo-meta.md +0 -0
- /package/{3.api → 4.api}/2.composables/use-state.md +0 -0
- /package/{3.api → 4.api}/3.utils/.navigation.yml +0 -0
- /package/{3.api → 4.api}/3.utils/clear-error.md +0 -0
- /package/{3.api → 4.api}/3.utils/clear-nuxt-data.md +0 -0
- /package/{3.api → 4.api}/3.utils/clear-nuxt-state.md +0 -0
- /package/{3.api → 4.api}/3.utils/create-error.md +0 -0
- /package/{3.api → 4.api}/3.utils/define-lazy-hydration-component.md +0 -0
- /package/{3.api → 4.api}/3.utils/define-nuxt-component.md +0 -0
- /package/{3.api → 4.api}/3.utils/define-route-rules.md +0 -0
- /package/{3.api → 4.api}/3.utils/on-before-route-leave.md +0 -0
- /package/{3.api → 4.api}/3.utils/on-before-route-update.md +0 -0
- /package/{3.api → 4.api}/3.utils/on-nuxt-ready.md +0 -0
- /package/{3.api → 4.api}/3.utils/prefetch-components.md +0 -0
- /package/{3.api → 4.api}/3.utils/preload-components.md +0 -0
- /package/{3.api → 4.api}/3.utils/preload-route-components.md +0 -0
- /package/{3.api → 4.api}/3.utils/prerender-routes.md +0 -0
- /package/{3.api → 4.api}/3.utils/refresh-nuxt-data.md +0 -0
- /package/{3.api → 4.api}/3.utils/reload-nuxt-app.md +0 -0
- /package/{3.api → 4.api}/3.utils/set-page-layout.md +0 -0
- /package/{3.api → 4.api}/3.utils/set-response-status.md +0 -0
- /package/{3.api → 4.api}/3.utils/show-error.md +0 -0
- /package/{3.api → 4.api}/4.commands/.navigation.yml +0 -0
- /package/{3.api → 4.api}/5.kit/.navigation.yml +0 -0
- /package/{3.api → 4.api}/5.kit/10.runtime-config.md +0 -0
- /package/{3.api → 4.api}/5.kit/12.resolving.md +0 -0
- /package/{3.api → 4.api}/5.kit/13.logging.md +0 -0
- /package/{3.api → 4.api}/5.kit/15.examples.md +0 -0
- /package/{3.api → 4.api}/5.kit/3.compatibility.md +0 -0
- /package/{3.api → 4.api}/5.kit/6.context.md +0 -0
- /package/{3.api → 4.api}/5.kit/7.pages.md +0 -0
- /package/{3.api → 4.api}/5.kit/8.layout.md +0 -0
- /package/{3.api → 4.api}/5.kit/9.head.md +0 -0
- /package/{3.api → 4.api}/5.kit/9.plugins.md +0 -0
- /package/{3.api → 4.api}/6.advanced/.navigation.yml +0 -0
- /package/{3.api → 4.api}/6.advanced/2.import-meta.md +0 -0
- /package/{3.api → 4.api}/index.md +0 -0
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: 'useCookie'
|
|
3
|
-
description: useCookie is an SSR-friendly composable to read and write cookies.
|
|
4
|
-
links:
|
|
5
|
-
- label: Source
|
|
6
|
-
icon: i-simple-icons-github
|
|
7
|
-
to: https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/app/composables/cookie.ts
|
|
8
|
-
size: xs
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
Within your pages, components, and plugins, you can use `useCookie` to read and write cookies in an SSR-friendly way.
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
const cookie = useCookie(name, options)
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
::note
|
|
20
|
-
`useCookie` only works in the [Nuxt context](/docs/4.x/guide/going-further/nuxt-app#the-nuxt-context).
|
|
21
|
-
::
|
|
22
|
-
|
|
23
|
-
::tip
|
|
24
|
-
The returned ref will automatically serialize and deserialize cookie values to JSON.
|
|
25
|
-
::
|
|
26
|
-
|
|
27
|
-
## Type
|
|
28
|
-
|
|
29
|
-
```ts [Signature]
|
|
30
|
-
import type { Ref } from 'vue'
|
|
31
|
-
import type { CookieParseOptions, CookieSerializeOptions } from 'cookie-es'
|
|
32
|
-
|
|
33
|
-
export interface CookieOptions<T = any> extends Omit<CookieSerializeOptions & CookieParseOptions, 'decode' | 'encode'> {
|
|
34
|
-
decode?(value: string): T
|
|
35
|
-
encode?(value: T): string
|
|
36
|
-
default?: () => T | Ref<T>
|
|
37
|
-
watch?: boolean | 'shallow'
|
|
38
|
-
readonly?: boolean
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface CookieRef<T> extends Ref<T> {}
|
|
42
|
-
|
|
43
|
-
export function useCookie<T = string | null | undefined> (
|
|
44
|
-
name: string,
|
|
45
|
-
options?: CookieOptions<T>,
|
|
46
|
-
): CookieRef<T>
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Parameters
|
|
50
|
-
|
|
51
|
-
`name`: The name of the cookie.
|
|
52
|
-
|
|
53
|
-
`options`: Options to control cookie behavior. The object can have the following properties:
|
|
54
|
-
|
|
55
|
-
Most of the options will be directly passed to the [cookie](https://github.com/jshttp/cookie) package.
|
|
56
|
-
|
|
57
|
-
| Property | Type | Default | Description |
|
|
58
|
-
| --- | --- | --- | --- |
|
|
59
|
-
| `decode` | `(value: string) => T` | `decodeURIComponent` + [destr](https://github.com/unjs/destr). | Custom function to decode the cookie value. Since the value of a cookie has a limited character set (and must be a simple string), this function can be used to decode a previously encoded cookie value into a JavaScript string or other object. <br/> **Note:** If an error is thrown from this function, the original, non-decoded cookie value will be returned as the cookie's value. |
|
|
60
|
-
| `encode` | `(value: T) => string` | `JSON.stringify` + `encodeURIComponent` | Custom function to encode the cookie value. Since the value of a cookie has a limited character set (and must be a simple string), this function can be used to encode a value into a string suited for a cookie's value. |
|
|
61
|
-
| `default` | `() => T \| Ref<T>` | `undefined` | Function returning the default value if the cookie does not exist. The function can also return a `Ref`. |
|
|
62
|
-
| `watch` | `boolean \| 'shallow'` | `true` | Whether to watch for changes and update the cookie. `true` for deep watch, `'shallow'` for shallow watch, i.e. data changes for only top level properties, `false` to disable. <br/> **Note:** Refresh `useCookie` values manually when a cookie has changed with [`refreshCookie`](/docs/4.x/api/utils/refresh-cookie). |
|
|
63
|
-
| `readonly` | `boolean` | `false` | If `true`, disables writing to the cookie. |
|
|
64
|
-
| `maxAge` | `number` | `undefined` | Max age in seconds for the cookie, i.e. the value for the [`Max-Age` `Set-Cookie` attribute](https://datatracker.ietf.org/doc/html/rfc6265#section-5.2.2). The given number will be converted to an integer by rounding down. By default, no maximum age is set. |
|
|
65
|
-
| `expires` | `Date` | `undefined` | Expiration date for the cookie. By default, no expiration is set. Most clients will consider this a "non-persistent cookie" and will delete it on a condition like exiting a web browser application. <br/> **Note:** The [cookie storage model specification](https://datatracker.ietf.org/doc/html/rfc6265#section-5.3) states that if both `expires` and `maxAge` is set, then `maxAge` takes precedence, but not all clients may obey this, so if both are set, they should point to the same date and time! <br/>If neither of `expires` and `maxAge` is set, the cookie will be session-only and removed when the user closes their browser. |
|
|
66
|
-
| `httpOnly` | `boolean` | `false` | Sets the HttpOnly attribute. <br/> **Note:** Be careful when setting this to `true`, as compliant clients will not allow client-side JavaScript to see the cookie in `document.cookie`. |
|
|
67
|
-
| `secure` | `boolean` | `false` | Sets the [`Secure` `Set-Cookie` attribute](https://datatracker.ietf.org/doc/html/rfc6265#section-5.2.5). <br/>**Note:** Be careful when setting this to `true`, as compliant clients will not send the cookie back to the server in the future if the browser does not have an HTTPS connection. This can lead to hydration errors. |
|
|
68
|
-
| `partitioned` | `boolean` | `false` | Sets the [`Partitioned` `Set-Cookie` attribute](https://datatracker.ietf.org/doc/html/draft-cutler-httpbis-partitioned-cookies#section-2.1). <br/>**Note:** This is an attribute that has not yet been fully standardized, and may change in the future. <br/>This also means many clients may ignore this attribute until they understand it.<br/>More information can be found in the [proposal](https://github.com/privacycg/CHIPS). |
|
|
69
|
-
| `domain` | `string` | `undefined` | Sets the [`Domain` `Set-Cookie` attribute](https://datatracker.ietf.org/doc/html/rfc6265#section-5.2.3). By default, no domain is set, and most clients will consider applying the cookie only to the current domain. |
|
|
70
|
-
| `path` | `string` | `'/'` | Sets the [`Path` `Set-Cookie` attribute](https://datatracker.ietf.org/doc/html/rfc6265#section-5.2.4). By default, the path is considered the ["default path"](https://datatracker.ietf.org/doc/html/rfc6265#section-5.1.4). |
|
|
71
|
-
| `sameSite` | `boolean \| string` | `undefined` | Sets the [`SameSite` `Set-Cookie` attribute](https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7). <br/>- `true` will set the `SameSite` attribute to `Strict` for strict same-site enforcement.<br/>- `false` will not set the `SameSite` attribute.<br/>- `'lax'` will set the `SameSite` attribute to `Lax` for lax same-site enforcement.<br/>- `'none'` will set the `SameSite` attribute to `None` for an explicit cross-site cookie.<br/>- `'strict'` will set the `SameSite` attribute to `Strict` for strict same-site enforcement. |
|
|
72
|
-
|
|
73
|
-
## Return Values
|
|
74
|
-
|
|
75
|
-
Returns a Vue `Ref<T>` representing the cookie value. Updating the ref will update the cookie (unless `readonly` is set). The ref is SSR-friendly and will work on both client and server.
|
|
76
|
-
|
|
77
|
-
## Examples
|
|
78
|
-
|
|
79
|
-
### Basic Usage
|
|
80
|
-
|
|
81
|
-
The example below creates a cookie called `counter`. If the cookie doesn't exist, it is initially set to a random value. Whenever we update the `counter` variable, the cookie will be updated accordingly.
|
|
82
|
-
|
|
83
|
-
```vue [app/app.vue]
|
|
84
|
-
<script setup lang="ts">
|
|
85
|
-
const counter = useCookie('counter')
|
|
86
|
-
|
|
87
|
-
counter.value ||= Math.round(Math.random() * 1000)
|
|
88
|
-
</script>
|
|
89
|
-
|
|
90
|
-
<template>
|
|
91
|
-
<div>
|
|
92
|
-
<h1>Counter: {{ counter || '-' }}</h1>
|
|
93
|
-
<button @click="counter = null">
|
|
94
|
-
reset
|
|
95
|
-
</button>
|
|
96
|
-
<button @click="counter--">
|
|
97
|
-
-
|
|
98
|
-
</button>
|
|
99
|
-
<button @click="counter++">
|
|
100
|
-
+
|
|
101
|
-
</button>
|
|
102
|
-
</div>
|
|
103
|
-
</template>
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### Readonly Cookies
|
|
107
|
-
|
|
108
|
-
```vue
|
|
109
|
-
<script setup lang="ts">
|
|
110
|
-
const user = useCookie(
|
|
111
|
-
'userInfo',
|
|
112
|
-
{
|
|
113
|
-
default: () => ({ score: -1 }),
|
|
114
|
-
watch: false,
|
|
115
|
-
},
|
|
116
|
-
)
|
|
117
|
-
|
|
118
|
-
if (user.value) {
|
|
119
|
-
// the actual `userInfo` cookie will not be updated
|
|
120
|
-
user.value.score++
|
|
121
|
-
}
|
|
122
|
-
</script>
|
|
123
|
-
|
|
124
|
-
<template>
|
|
125
|
-
<div>User score: {{ user?.score }}</div>
|
|
126
|
-
</template>
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### Writable Cookies
|
|
130
|
-
|
|
131
|
-
```vue
|
|
132
|
-
<script setup lang="ts">
|
|
133
|
-
const list = useCookie(
|
|
134
|
-
'list',
|
|
135
|
-
{
|
|
136
|
-
default: () => [],
|
|
137
|
-
watch: 'shallow',
|
|
138
|
-
},
|
|
139
|
-
)
|
|
140
|
-
|
|
141
|
-
function add () {
|
|
142
|
-
list.value?.push(Math.round(Math.random() * 1000))
|
|
143
|
-
// list cookie won't be updated with this change
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function save () {
|
|
147
|
-
// the actual `list` cookie will be updated
|
|
148
|
-
list.value &&= [...list.value]
|
|
149
|
-
}
|
|
150
|
-
</script>
|
|
151
|
-
|
|
152
|
-
<template>
|
|
153
|
-
<div>
|
|
154
|
-
<h1>List</h1>
|
|
155
|
-
<pre>{{ list }}</pre>
|
|
156
|
-
<button @click="add">
|
|
157
|
-
Add
|
|
158
|
-
</button>
|
|
159
|
-
<button @click="save">
|
|
160
|
-
Save
|
|
161
|
-
</button>
|
|
162
|
-
</div>
|
|
163
|
-
</template>
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
### Cookies in API Routes
|
|
167
|
-
|
|
168
|
-
You can use `getCookie` and `setCookie` from [`h3`](https://github.com/h3js/h3) package to set cookies in server API routes.
|
|
169
|
-
|
|
170
|
-
```ts [server/api/counter.ts]
|
|
171
|
-
export default defineEventHandler((event) => {
|
|
172
|
-
// Read counter cookie
|
|
173
|
-
let counter = getCookie(event, 'counter') || 0
|
|
174
|
-
|
|
175
|
-
// Increase counter cookie by 1
|
|
176
|
-
setCookie(event, 'counter', ++counter)
|
|
177
|
-
|
|
178
|
-
// Send JSON response
|
|
179
|
-
return { counter }
|
|
180
|
-
})
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
:link-example{to="/docs/4.x/examples/advanced/use-cookie"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "nuxt analyze"
|
|
3
|
-
description: "Analyze the production bundle or your Nuxt application."
|
|
4
|
-
links:
|
|
5
|
-
- label: Source
|
|
6
|
-
icon: i-simple-icons-github
|
|
7
|
-
to: https://github.com/nuxt/cli/blob/main/packages/nuxi/src/commands/analyze.ts
|
|
8
|
-
size: xs
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
<!--analyze-cmd-->
|
|
12
|
-
```bash [Terminal]
|
|
13
|
-
npx nuxt analyze [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--dotenv] [-e, --extends=<layer-name>] [--name=<name>] [--no-serve]
|
|
14
|
-
```
|
|
15
|
-
<!--/analyze-cmd-->
|
|
16
|
-
|
|
17
|
-
The `analyze` command builds Nuxt and analyzes the production bundle (experimental).
|
|
18
|
-
|
|
19
|
-
## Arguments
|
|
20
|
-
|
|
21
|
-
<!--analyze-args-->
|
|
22
|
-
Argument | Description
|
|
23
|
-
--- | ---
|
|
24
|
-
`ROOTDIR="."` | Specifies the working directory (default: `.`)
|
|
25
|
-
<!--/analyze-args-->
|
|
26
|
-
|
|
27
|
-
## Options
|
|
28
|
-
|
|
29
|
-
<!--analyze-opts-->
|
|
30
|
-
Option | Default | Description
|
|
31
|
-
--- | --- | ---
|
|
32
|
-
`--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`)
|
|
33
|
-
`--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
|
|
34
|
-
`--dotenv` | | Path to `.env` file to load, relative to the root directory
|
|
35
|
-
`-e, --extends=<layer-name>` | | Extend from a Nuxt layer
|
|
36
|
-
`--name=<name>` | `default` | Name of the analysis
|
|
37
|
-
`--no-serve` | | Skip serving the analysis results
|
|
38
|
-
<!--/analyze-opts-->
|
|
39
|
-
|
|
40
|
-
::note
|
|
41
|
-
This command sets `process.env.NODE_ENV` to `production`.
|
|
42
|
-
::
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: 'nuxt build-module'
|
|
3
|
-
description: 'Nuxt command to build your Nuxt module before publishing.'
|
|
4
|
-
links:
|
|
5
|
-
- label: Source
|
|
6
|
-
icon: i-simple-icons-github
|
|
7
|
-
to: https://github.com/nuxt/module-builder/blob/main/src/cli.ts
|
|
8
|
-
size: xs
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
<!--build-module-cmd-->
|
|
12
|
-
```bash [Terminal]
|
|
13
|
-
npx nuxt build-module [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--build] [--stub] [--sourcemap] [--prepare]
|
|
14
|
-
```
|
|
15
|
-
<!--/build-module-cmd-->
|
|
16
|
-
|
|
17
|
-
The `build-module` command runs `@nuxt/module-builder` to generate `dist` directory within your `rootDir` that contains the full build for your **nuxt-module**.
|
|
18
|
-
|
|
19
|
-
## Arguments
|
|
20
|
-
|
|
21
|
-
<!--build-module-args-->
|
|
22
|
-
Argument | Description
|
|
23
|
-
--- | ---
|
|
24
|
-
`ROOTDIR="."` | Specifies the working directory (default: `.`)
|
|
25
|
-
<!--/build-module-args-->
|
|
26
|
-
|
|
27
|
-
## Options
|
|
28
|
-
|
|
29
|
-
<!--build-module-opts-->
|
|
30
|
-
Option | Default | Description
|
|
31
|
-
--- | --- | ---
|
|
32
|
-
`--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`)
|
|
33
|
-
`--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
|
|
34
|
-
`--build` | `false` | Build module for distribution
|
|
35
|
-
`--stub` | `false` | Stub dist instead of actually building it for development
|
|
36
|
-
`--sourcemap` | `false` | Generate sourcemaps
|
|
37
|
-
`--prepare` | `false` | Prepare module for local development
|
|
38
|
-
<!--/build-module-opts-->
|
|
39
|
-
|
|
40
|
-
::read-more{to="https://github.com/nuxt/module-builder" icon="i-simple-icons-github" target="\_blank"}
|
|
41
|
-
Read more about `@nuxt/module-builder`.
|
|
42
|
-
::
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "nuxt build"
|
|
3
|
-
description: "Build your Nuxt application."
|
|
4
|
-
links:
|
|
5
|
-
- label: Source
|
|
6
|
-
icon: i-simple-icons-github
|
|
7
|
-
to: https://github.com/nuxt/cli/blob/main/packages/nuxi/src/commands/build.ts
|
|
8
|
-
size: xs
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
<!--build-cmd-->
|
|
12
|
-
```bash [Terminal]
|
|
13
|
-
npx nuxt build [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--prerender] [--preset] [--dotenv] [--envName] [-e, --extends=<layer-name>]
|
|
14
|
-
```
|
|
15
|
-
<!--/build-cmd-->
|
|
16
|
-
|
|
17
|
-
The `build` command creates a `.output` directory with all your application, server and dependencies ready for production.
|
|
18
|
-
|
|
19
|
-
## Arguments
|
|
20
|
-
|
|
21
|
-
<!--build-args-->
|
|
22
|
-
Argument | Description
|
|
23
|
-
--- | ---
|
|
24
|
-
`ROOTDIR="."` | Specifies the working directory (default: `.`)
|
|
25
|
-
<!--/build-args-->
|
|
26
|
-
|
|
27
|
-
## Options
|
|
28
|
-
|
|
29
|
-
<!--build-opts-->
|
|
30
|
-
Option | Default | Description
|
|
31
|
-
--- | --- | ---
|
|
32
|
-
`--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`)
|
|
33
|
-
`--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
|
|
34
|
-
`--prerender` | | Build Nuxt and prerender static routes
|
|
35
|
-
`--preset` | | Nitro server preset
|
|
36
|
-
`--dotenv` | | Path to `.env` file to load, relative to the root directory
|
|
37
|
-
`--envName` | | The environment to use when resolving configuration overrides (default is `production` when building, and `development` when running the dev server)
|
|
38
|
-
`-e, --extends=<layer-name>` | | Extend from a Nuxt layer
|
|
39
|
-
<!--/build-opts-->
|
|
40
|
-
|
|
41
|
-
::note
|
|
42
|
-
This command sets `process.env.NODE_ENV` to `production`.
|
|
43
|
-
::
|
|
44
|
-
|
|
45
|
-
::note
|
|
46
|
-
`--prerender` will always set the `preset` to `static`
|
|
47
|
-
::
|
package/3.api/4.commands/dev.md
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: 'nuxt dev'
|
|
3
|
-
description: The dev command starts a development server with hot module replacement at http://localhost:3000
|
|
4
|
-
links:
|
|
5
|
-
- label: Source
|
|
6
|
-
icon: i-simple-icons-github
|
|
7
|
-
to: https://github.com/nuxt/cli/blob/main/packages/nuxi/src/commands/dev.ts
|
|
8
|
-
size: xs
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
<!--dev-cmd-->
|
|
12
|
-
```bash [Terminal]
|
|
13
|
-
npx nuxt dev [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--dotenv] [--envName] [-e, --extends=<layer-name>] [--clear] [--no-f, --no-fork] [-p, --port] [-h, --host] [--clipboard] [-o, --open] [--https] [--publicURL] [--qr] [--public] [--tunnel] [--sslCert] [--sslKey]
|
|
14
|
-
```
|
|
15
|
-
<!--/dev-cmd-->
|
|
16
|
-
|
|
17
|
-
The `dev` command starts a development server with hot module replacement at [http://localhost:3000](https://localhost:3000)
|
|
18
|
-
|
|
19
|
-
## Arguments
|
|
20
|
-
|
|
21
|
-
<!--dev-args-->
|
|
22
|
-
Argument | Description
|
|
23
|
-
--- | ---
|
|
24
|
-
`ROOTDIR="."` | Specifies the working directory (default: `.`)
|
|
25
|
-
<!--/dev-args-->
|
|
26
|
-
|
|
27
|
-
## Options
|
|
28
|
-
|
|
29
|
-
<!--dev-opts-->
|
|
30
|
-
Option | Default | Description
|
|
31
|
-
--- | --- | ---
|
|
32
|
-
`--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`)
|
|
33
|
-
`--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
|
|
34
|
-
`--dotenv` | | Path to `.env` file to load, relative to the root directory
|
|
35
|
-
`--envName` | | The environment to use when resolving configuration overrides (default is `production` when building, and `development` when running the dev server)
|
|
36
|
-
`-e, --extends=<layer-name>` | | Extend from a Nuxt layer
|
|
37
|
-
`--clear` | `false` | Clear console on restart
|
|
38
|
-
`--no-f, --no-fork` | | Disable forked mode
|
|
39
|
-
`-p, --port` | | Port to listen on (default: `NUXT_PORT \|\| NITRO_PORT \|\| PORT \|\| nuxtOptions.devServer.port`)
|
|
40
|
-
`-h, --host` | | Host to listen on (default: `NUXT_HOST \|\| NITRO_HOST \|\| HOST \|\| nuxtOptions.devServer?.host`)
|
|
41
|
-
`--clipboard` | `false` | Copy the URL to the clipboard
|
|
42
|
-
`-o, --open` | `false` | Open the URL in the browser
|
|
43
|
-
`--https` | | Enable HTTPS
|
|
44
|
-
`--publicURL` | | Displayed public URL (used for QR code)
|
|
45
|
-
`--qr` | | Display The QR code of public URL when available
|
|
46
|
-
`--public` | | Listen to all network interfaces
|
|
47
|
-
`--tunnel` | | Open a tunnel using https://github.com/unjs/untun
|
|
48
|
-
`--sslCert` | | (DEPRECATED) Use `--https.cert` instead.
|
|
49
|
-
`--sslKey` | | (DEPRECATED) Use `--https.key` instead.
|
|
50
|
-
<!--/dev-opts-->
|
|
51
|
-
|
|
52
|
-
The port and host can also be set via NUXT_PORT, PORT, NUXT_HOST or HOST environment variables.
|
|
53
|
-
|
|
54
|
-
Additionally to the above options, `@nuxt/cli` can pass options through to `listhen`, e.g. `--no-qr` to turn off the dev server QR code. You can find the list of `listhen` options in the [unjs/listhen](https://github.com/unjs/listhen) docs.
|
|
55
|
-
|
|
56
|
-
This command sets `process.env.NODE_ENV` to `development`.
|
|
57
|
-
|
|
58
|
-
::note
|
|
59
|
-
If you are using a self-signed certificate in development, you will need to set `NODE_TLS_REJECT_UNAUTHORIZED=0` in your environment.
|
|
60
|
-
::
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "nuxt generate"
|
|
3
|
-
description: Pre-renders every route of the application and stores the result in plain HTML files.
|
|
4
|
-
links:
|
|
5
|
-
- label: Source
|
|
6
|
-
icon: i-simple-icons-github
|
|
7
|
-
to: https://github.com/nuxt/cli/blob/main/packages/nuxi/src/commands/generate.ts
|
|
8
|
-
size: xs
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
<!--generate-cmd-->
|
|
12
|
-
```bash [Terminal]
|
|
13
|
-
npx nuxt generate [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--preset] [--dotenv] [--envName] [-e, --extends=<layer-name>]
|
|
14
|
-
```
|
|
15
|
-
<!--/generate-cmd-->
|
|
16
|
-
|
|
17
|
-
The `generate` command pre-renders every route of your application and stores the result in plain HTML files that you can deploy on any static hosting services. The command triggers the `nuxt build` command with the `prerender` argument set to `true`
|
|
18
|
-
|
|
19
|
-
## Arguments
|
|
20
|
-
|
|
21
|
-
<!--generate-args-->
|
|
22
|
-
Argument | Description
|
|
23
|
-
--- | ---
|
|
24
|
-
`ROOTDIR="."` | Specifies the working directory (default: `.`)
|
|
25
|
-
<!--/generate-args-->
|
|
26
|
-
|
|
27
|
-
## Options
|
|
28
|
-
|
|
29
|
-
<!--generate-opts-->
|
|
30
|
-
Option | Default | Description
|
|
31
|
-
--- | --- | ---
|
|
32
|
-
`--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`)
|
|
33
|
-
`--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
|
|
34
|
-
`--preset` | | Nitro server preset
|
|
35
|
-
`--dotenv` | | Path to `.env` file to load, relative to the root directory
|
|
36
|
-
`--envName` | | The environment to use when resolving configuration overrides (default is `production` when building, and `development` when running the dev server)
|
|
37
|
-
`-e, --extends=<layer-name>` | | Extend from a Nuxt layer
|
|
38
|
-
<!--/generate-opts-->
|
|
39
|
-
|
|
40
|
-
::read-more{to="/docs/4.x/getting-started/deployment#static-hosting"}
|
|
41
|
-
Read more about pre-rendering and static hosting.
|
|
42
|
-
::
|
package/3.api/4.commands/info.md
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "nuxt info"
|
|
3
|
-
description: The info command logs information about the current or specified Nuxt project.
|
|
4
|
-
links:
|
|
5
|
-
- label: Source
|
|
6
|
-
icon: i-simple-icons-github
|
|
7
|
-
to: https://github.com/nuxt/cli/blob/main/packages/nuxi/src/commands/info.ts
|
|
8
|
-
size: xs
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
<!--info-cmd-->
|
|
12
|
-
```bash [Terminal]
|
|
13
|
-
npx nuxt info [ROOTDIR] [--cwd=<directory>]
|
|
14
|
-
```
|
|
15
|
-
<!--/info-cmd-->
|
|
16
|
-
|
|
17
|
-
The `info` command logs information about the current or specified Nuxt project.
|
|
18
|
-
|
|
19
|
-
## Arguments
|
|
20
|
-
|
|
21
|
-
<!--info-args-->
|
|
22
|
-
Argument | Description
|
|
23
|
-
--- | ---
|
|
24
|
-
`ROOTDIR="."` | Specifies the working directory (default: `.`)
|
|
25
|
-
<!--/info-args-->
|
|
26
|
-
|
|
27
|
-
## Options
|
|
28
|
-
|
|
29
|
-
<!--info-opts-->
|
|
30
|
-
Option | Default | Description
|
|
31
|
-
--- | --- | ---
|
|
32
|
-
`--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`)
|
|
33
|
-
<!--/info-opts-->
|
package/3.api/4.commands/init.md
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "create nuxt"
|
|
3
|
-
description: The init command initializes a fresh Nuxt project.
|
|
4
|
-
links:
|
|
5
|
-
- label: Source
|
|
6
|
-
icon: i-simple-icons-github
|
|
7
|
-
to: https://github.com/nuxt/cli/blob/main/packages/nuxi/src/commands/init.ts
|
|
8
|
-
size: xs
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
<!--init-cmd-->
|
|
12
|
-
```bash [Terminal]
|
|
13
|
-
npm create nuxt@latest [DIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [-t, --template] [-f, --force] [--offline] [--preferOffline] [--no-install] [--gitInit] [--shell] [--packageManager] [-M, --modules] [--no-modules] [--nightly]
|
|
14
|
-
```
|
|
15
|
-
<!--/init-cmd-->
|
|
16
|
-
|
|
17
|
-
The `create-nuxt` command initializes a fresh Nuxt project using [unjs/giget](https://github.com/unjs/giget).
|
|
18
|
-
|
|
19
|
-
## Arguments
|
|
20
|
-
|
|
21
|
-
<!--init-args-->
|
|
22
|
-
Argument | Description
|
|
23
|
-
--- | ---
|
|
24
|
-
`DIR=""` | Project directory
|
|
25
|
-
<!--/init-args-->
|
|
26
|
-
|
|
27
|
-
## Options
|
|
28
|
-
|
|
29
|
-
<!--init-opts-->
|
|
30
|
-
Option | Default | Description
|
|
31
|
-
--- | --- | ---
|
|
32
|
-
`--cwd=<directory>` | `.` | Specify the working directory
|
|
33
|
-
`--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
|
|
34
|
-
`-t, --template` | | Template name
|
|
35
|
-
`-f, --force` | | Override existing directory
|
|
36
|
-
`--offline` | | Force offline mode
|
|
37
|
-
`--preferOffline` | | Prefer offline mode
|
|
38
|
-
`--no-install` | | Skip installing dependencies
|
|
39
|
-
`--gitInit` | | Initialize git repository
|
|
40
|
-
`--shell` | | Start shell after installation in project directory
|
|
41
|
-
`--packageManager` | | Package manager choice (npm, pnpm, yarn, bun)
|
|
42
|
-
`-M, --modules` | | Nuxt modules to install (comma separated without spaces)
|
|
43
|
-
`--no-modules` | | Skip module installation prompt
|
|
44
|
-
`--nightly` | | Use Nuxt nightly release channel (3x or latest)
|
|
45
|
-
<!--/init-opts-->
|
|
46
|
-
|
|
47
|
-
## Environment variables
|
|
48
|
-
|
|
49
|
-
- `NUXI_INIT_REGISTRY`: Set to a custom template registry. ([learn more](https://github.com/unjs/giget#custom-registry)).
|
|
50
|
-
- Default registry is loaded from [nuxt/starter/templates](https://github.com/nuxt/starter/tree/templates/templates)
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "nuxt module"
|
|
3
|
-
description: "Search and add modules to your Nuxt application with the command line."
|
|
4
|
-
links:
|
|
5
|
-
- label: Source
|
|
6
|
-
icon: i-simple-icons-github
|
|
7
|
-
to: https://github.com/nuxt/cli/blob/main/packages/nuxi/src/commands/module/
|
|
8
|
-
size: xs
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
Nuxt provides a few utilities to work with [Nuxt modules](/modules) seamlessly.
|
|
12
|
-
|
|
13
|
-
## nuxt module add
|
|
14
|
-
|
|
15
|
-
<!--module-add-cmd-->
|
|
16
|
-
```bash [Terminal]
|
|
17
|
-
npx nuxt module add <MODULENAME> [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--skipInstall] [--skipConfig] [--dev]
|
|
18
|
-
```
|
|
19
|
-
<!--/module-add-cmd-->
|
|
20
|
-
|
|
21
|
-
<!--module-add-args-->
|
|
22
|
-
Argument | Description
|
|
23
|
-
--- | ---
|
|
24
|
-
`MODULENAME` | Specify one or more modules to install by name, separated by spaces
|
|
25
|
-
<!--/module-add-args-->
|
|
26
|
-
|
|
27
|
-
<!--module-add-opts-->
|
|
28
|
-
Option | Default | Description
|
|
29
|
-
--- | --- | ---
|
|
30
|
-
`--cwd=<directory>` | `.` | Specify the working directory
|
|
31
|
-
`--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
|
|
32
|
-
`--skipInstall` | | Skip npm install
|
|
33
|
-
`--skipConfig` | | Skip nuxt.config.ts update
|
|
34
|
-
`--dev` | | Install modules as dev dependencies
|
|
35
|
-
<!--/module-add-opts-->
|
|
36
|
-
|
|
37
|
-
The command lets you install [Nuxt modules](/modules) in your application with no manual work.
|
|
38
|
-
|
|
39
|
-
When running the command, it will:
|
|
40
|
-
|
|
41
|
-
- install the module as a dependency using your package manager
|
|
42
|
-
- add it to your [package.json](/docs/4.x/guide/directory-structure/package) file
|
|
43
|
-
- update your [`nuxt.config`](/docs/4.x/guide/directory-structure/nuxt-config) file
|
|
44
|
-
|
|
45
|
-
**Example:**
|
|
46
|
-
|
|
47
|
-
Installing the [`Pinia`](/modules/pinia) module
|
|
48
|
-
|
|
49
|
-
```bash [Terminal]
|
|
50
|
-
npx nuxt module add pinia
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
## nuxt module search
|
|
54
|
-
|
|
55
|
-
<!--module-search-cmd-->
|
|
56
|
-
```bash [Terminal]
|
|
57
|
-
npx nuxt module search <QUERY> [--cwd=<directory>] [--nuxtVersion=<2|3>]
|
|
58
|
-
```
|
|
59
|
-
<!--/module-search-cmd-->
|
|
60
|
-
|
|
61
|
-
### Arguments
|
|
62
|
-
|
|
63
|
-
<!--module-search-args-->
|
|
64
|
-
Argument | Description
|
|
65
|
-
--- | ---
|
|
66
|
-
`QUERY` | keywords to search for
|
|
67
|
-
<!--/module-search-args-->
|
|
68
|
-
|
|
69
|
-
### Options
|
|
70
|
-
|
|
71
|
-
<!--module-search-opts-->
|
|
72
|
-
Option | Default | Description
|
|
73
|
-
--- | --- | ---
|
|
74
|
-
`--cwd=<directory>` | `.` | Specify the working directory
|
|
75
|
-
`--nuxtVersion=<2\|3>` | | Filter by Nuxt version and list compatible modules only (auto detected by default)
|
|
76
|
-
<!--/module-search-opts-->
|
|
77
|
-
|
|
78
|
-
The command searches for Nuxt modules matching your query that are compatible with your Nuxt version.
|
|
79
|
-
|
|
80
|
-
**Example:**
|
|
81
|
-
|
|
82
|
-
```bash [Terminal]
|
|
83
|
-
npx nuxt module search pinia
|
|
84
|
-
```
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: 'nuxt prepare'
|
|
3
|
-
description: The prepare command creates a .nuxt directory in your application and generates types.
|
|
4
|
-
links:
|
|
5
|
-
- label: Source
|
|
6
|
-
icon: i-simple-icons-github
|
|
7
|
-
to: https://github.com/nuxt/cli/blob/main/packages/nuxi/src/commands/prepare.ts
|
|
8
|
-
size: xs
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
<!--prepare-cmd-->
|
|
12
|
-
```bash [Terminal]
|
|
13
|
-
npx nuxt prepare [ROOTDIR] [--dotenv] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--envName] [-e, --extends=<layer-name>]
|
|
14
|
-
```
|
|
15
|
-
<!--/prepare-cmd-->
|
|
16
|
-
|
|
17
|
-
The `prepare` command creates a [`.nuxt`](/docs/4.x/guide/directory-structure/nuxt) directory in your application and generates types. This can be useful in a CI environment or as a `postinstall` command in your [`package.json`](/docs/4.x/guide/directory-structure/package).
|
|
18
|
-
|
|
19
|
-
## Arguments
|
|
20
|
-
|
|
21
|
-
<!--prepare-args-->
|
|
22
|
-
Argument | Description
|
|
23
|
-
--- | ---
|
|
24
|
-
`ROOTDIR="."` | Specifies the working directory (default: `.`)
|
|
25
|
-
<!--/prepare-args-->
|
|
26
|
-
|
|
27
|
-
## Options
|
|
28
|
-
|
|
29
|
-
<!--prepare-opts-->
|
|
30
|
-
Option | Default | Description
|
|
31
|
-
--- | --- | ---
|
|
32
|
-
`--dotenv` | | Path to `.env` file to load, relative to the root directory
|
|
33
|
-
`--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`)
|
|
34
|
-
`--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
|
|
35
|
-
`--envName` | | The environment to use when resolving configuration overrides (default is `production` when building, and `development` when running the dev server)
|
|
36
|
-
`-e, --extends=<layer-name>` | | Extend from a Nuxt layer
|
|
37
|
-
<!--/prepare-opts-->
|
|
38
|
-
|
|
39
|
-
::note
|
|
40
|
-
This command sets `process.env.NODE_ENV` to `production`.
|
|
41
|
-
::
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "nuxt preview"
|
|
3
|
-
description: The preview command starts a server to preview your application after the build command.
|
|
4
|
-
links:
|
|
5
|
-
- label: Source
|
|
6
|
-
icon: i-simple-icons-github
|
|
7
|
-
to: https://github.com/nuxt/cli/blob/main/packages/nuxi/src/commands/preview.ts
|
|
8
|
-
size: xs
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
<!--preview-cmd-->
|
|
12
|
-
```bash [Terminal]
|
|
13
|
-
npx nuxt preview [ROOTDIR] [--cwd=<directory>] [--logLevel=<silent|info|verbose>] [--envName] [-e, --extends=<layer-name>] [-p, --port] [--dotenv]
|
|
14
|
-
```
|
|
15
|
-
<!--/preview-cmd-->
|
|
16
|
-
|
|
17
|
-
The `preview` command starts a server to preview your Nuxt application after running the `build` command. The `start` command is an alias for `preview`. When running your application in production refer to the [Deployment section](/docs/4.x/getting-started/deployment).
|
|
18
|
-
|
|
19
|
-
## Arguments
|
|
20
|
-
|
|
21
|
-
<!--preview-args-->
|
|
22
|
-
Argument | Description
|
|
23
|
-
--- | ---
|
|
24
|
-
`ROOTDIR="."` | Specifies the working directory (default: `.`)
|
|
25
|
-
<!--/preview-args-->
|
|
26
|
-
|
|
27
|
-
## Options
|
|
28
|
-
|
|
29
|
-
<!--preview-opts-->
|
|
30
|
-
Option | Default | Description
|
|
31
|
-
--- | --- | ---
|
|
32
|
-
`--cwd=<directory>` | | Specify the working directory, this takes precedence over ROOTDIR (default: `.`)
|
|
33
|
-
`--logLevel=<silent\|info\|verbose>` | | Specify build-time log level
|
|
34
|
-
`--envName` | | The environment to use when resolving configuration overrides (default is `production` when building, and `development` when running the dev server)
|
|
35
|
-
`-e, --extends=<layer-name>` | | Extend from a Nuxt layer
|
|
36
|
-
`-p, --port` | | Port to listen on (use `PORT` environment variable to override)
|
|
37
|
-
`--dotenv` | | Path to `.env` file to load, relative to the root directory
|
|
38
|
-
<!--/preview-opts-->
|
|
39
|
-
|
|
40
|
-
This command sets `process.env.NODE_ENV` to `production`. To override, define `NODE_ENV` in a `.env` file or as command-line argument.
|
|
41
|
-
|
|
42
|
-
::note
|
|
43
|
-
For convenience, in preview mode, your [`.env`](/docs/4.x/guide/directory-structure/env) file will be loaded into `process.env`. (However, in production you will need to ensure your environment variables are set yourself. For example, with Node.js 20+ you could do this by running `node --env-file .env .output/server/index.mjs` to start your server.)
|
|
44
|
-
::
|