4837 lines
No EOL
186 KiB
TypeScript
4837 lines
No EOL
186 KiB
TypeScript
import { BuiltinPresetName, Unimport } from "unimport";
|
||
import { AppConfig, KeepAliveProps, TransitionProps } from "vue";
|
||
import { Plugin, ServerOptions, UserConfig, ViteDevServer } from "vite";
|
||
import { Compiler, Configuration, Stats, WebpackError, WebpackPluginInstance } from "webpack";
|
||
import { Options } from "@vitejs/plugin-vue";
|
||
import { Options as Options$1 } from "@vitejs/plugin-vue-jsx";
|
||
import { InputObject, Schema, SchemaDefinition, SchemaDefinition as SchemaDefinition$1 } from "untyped";
|
||
import { RouteLocationNormalizedGeneric, RouteLocationRaw, RouteRecordRaw, RouterHistory, RouterOptions } from "vue-router";
|
||
import { IncomingMessage, Server, ServerResponse } from "node:http";
|
||
import { AssetURLTagConfig } from "@vue/compiler-sfc";
|
||
import { CompilerOptions } from "@vue/compiler-core";
|
||
import { AriaAttributes, DataKeys, GlobalAttributes, RenderSSRHeadOptions, SerializableHead } from "@unhead/vue/types";
|
||
import { UnheadVueViteOptions } from "@unhead/vue/vite";
|
||
import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer";
|
||
import { PluginVisualizerOptions } from "rollup-plugin-visualizer";
|
||
import { TransformerOptions } from "unctx/transform";
|
||
import { CompatibilityDateSpec } from "compatx";
|
||
import { ChokidarOptions } from "chokidar";
|
||
import { CorsOptions, H3CorsOptions } from "h3";
|
||
import { Options as Options$2 } from "autoprefixer";
|
||
import { Options as Options$3 } from "cssnano";
|
||
import { TSConfig } from "pkg-types";
|
||
import { RawVueCompilerOptions } from "@vue/language-core";
|
||
import { PluginOptions } from "mini-css-extract-plugin";
|
||
import { LoaderOptions } from "esbuild-loader";
|
||
import { Options as Options$4 } from "pug";
|
||
import { VueLoaderOptions } from "vue-loader";
|
||
import { BasePluginOptions, DefinedDefaultMinimizerAndOptions } from "css-minimizer-webpack-plugin";
|
||
import { ProcessOptions } from "postcss";
|
||
import { Options as Options$5 } from "webpack-dev-middleware";
|
||
import { ClientOptions, MiddlewareOptions } from "webpack-hot-middleware";
|
||
import { TransformOptions } from "oxc-transform";
|
||
import { TransformOptions as TransformOptions$1 } from "esbuild";
|
||
import { Server as Server$1 } from "node:https";
|
||
import { AsyncLocalStorage } from "node:async_hooks";
|
||
/**
|
||
* Names of the auto-import presets shipped by `unimport`, such as `'vue'` or `'vue-router'`.
|
||
*
|
||
* The list belongs to `unimport`, which is handed `imports.presets` unchanged, so it is
|
||
* re-exported rather than reimplemented: a name Nuxt made up would be a name that resolves to
|
||
* nothing at build time.
|
||
*/
|
||
type NuxtImportPresetName = BuiltinPresetName;
|
||
/** How an auto-imported binding is declared in generated type declarations. */
|
||
type NuxtImportDeclarationType = "let" | "var" | "const" | "enum" | "const enum" | "class" | "function" | "async function";
|
||
/** Options shared between a single auto-import and a preset of auto-imports. */
|
||
interface NuxtImportCommon {
|
||
/** Module specifier the import is resolved from. */
|
||
from: string;
|
||
/**
|
||
* Priority of the import. Where two imports share a name, the higher priority wins.
|
||
* @default 1
|
||
*/
|
||
priority?: number;
|
||
/** Whether this import is disabled. */
|
||
disabled?: boolean;
|
||
/** Whether to omit this import from generated type declarations. */
|
||
dtsDisabled?: boolean;
|
||
/** How the binding is declared in generated type declarations. */
|
||
declarationType?: NuxtImportDeclarationType;
|
||
meta?: {
|
||
/** Short description of the import, shown in editor tooling. */
|
||
description?: string;
|
||
/** URL to documentation for the import. */
|
||
docsUrl?: string;
|
||
[key: string]: any;
|
||
};
|
||
/** Whether this import is a type-only import. */
|
||
type?: boolean;
|
||
/** Module specifier to use in generated type declarations, if it differs from `from`. */
|
||
typeFrom?: string;
|
||
}
|
||
/** A single auto-imported binding. */
|
||
interface NuxtImport extends NuxtImportCommon {
|
||
/** Name of the export to import. */
|
||
name: string;
|
||
/** Name to make the export available as, if it differs from `name`. */
|
||
as?: string;
|
||
/** Import attributes. Ignored for CommonJS output. */
|
||
with?: Record<string, string>;
|
||
}
|
||
/**
|
||
* An entry in a preset's `imports`: an export name, a `[name, as?, from?]` tuple, or a full
|
||
* import without `from` (which is inherited from the preset).
|
||
*/
|
||
type NuxtImportEntry = Omit<NuxtImport, "from"> | string | [name: string, as?: string, from?: string];
|
||
/** A set of auto-imports declared inline, sharing a module specifier and options. */
|
||
interface NuxtImportPreset extends NuxtImportCommon {
|
||
imports: (NuxtImportEntry | NuxtImportPreset)[];
|
||
}
|
||
/** A set of auto-imports derived by scanning a package's exports. */
|
||
interface NuxtPackageImportPreset {
|
||
/** Name of the package to scan. */
|
||
package: string;
|
||
/**
|
||
* Path to resolve the package from.
|
||
* @default process.cwd()
|
||
*/
|
||
url?: string;
|
||
/** Names to exclude from the scanned exports. */
|
||
ignore?: (string | RegExp | ((name: string) => boolean))[];
|
||
/**
|
||
* Use a cached scan of the package, if one is available.
|
||
* @default true
|
||
*/
|
||
cache?: boolean;
|
||
}
|
||
/** A source of auto-imports: either declared inline, or scanned from a package. */
|
||
type NuxtImportPresetSource = NuxtImportPreset | NuxtPackageImportPreset;
|
||
/** A directory to scan for auto-imports, with per-directory options. */
|
||
interface NuxtImportScanDir {
|
||
/** Glob pattern matching the directory to scan. */
|
||
glob: string;
|
||
/**
|
||
* Register type exports found in the directory.
|
||
* @default true
|
||
*/
|
||
types?: boolean;
|
||
}
|
||
/** Options for scanning directories for auto-imports. */
|
||
interface NuxtImportScanOptions {
|
||
/**
|
||
* Glob patterns matching files to scan.
|
||
* @default ['*.{ts,js,mjs,cjs,mts,cts,tsx,jsx}']
|
||
*/
|
||
filePatterns?: string[];
|
||
/** Filter the scanned files. */
|
||
fileFilter?: (file: string) => boolean;
|
||
/**
|
||
* Register type exports.
|
||
* @default true
|
||
*/
|
||
types?: boolean;
|
||
/**
|
||
* Directory to resolve `filePatterns` against.
|
||
* @default process.cwd()
|
||
*/
|
||
cwd?: string;
|
||
}
|
||
/**
|
||
* Addons extending how auto-imports are injected.
|
||
*
|
||
* The addon protocol belongs to the transformer Nuxt uses internally, so entries in `addons`
|
||
* are not typed here.
|
||
*/
|
||
interface NuxtImportAddonsOptions {
|
||
addons?: any[];
|
||
/**
|
||
* Auto-import inside Vue SFC `<template>` blocks.
|
||
* @default false
|
||
*/
|
||
vueTemplate?: boolean;
|
||
/**
|
||
* Auto-import Vue directives used in SFC templates. Library authors should set
|
||
* `meta.vueDirective` on the import; `isDirective` is consulted for local directives only.
|
||
*/
|
||
vueDirectives?: true | {
|
||
isDirective?: (from: string, importEntry: NuxtImport) => boolean;
|
||
};
|
||
}
|
||
interface ImportsOptions {
|
||
/**
|
||
* Enable implicit auto import from Vue, Nuxt and module contributed utilities.
|
||
* Generate global TypeScript definitions.
|
||
*/
|
||
autoImport?: boolean;
|
||
/**
|
||
* Directories to scan for auto imports.
|
||
* @see https://nuxt.com/docs/4.x/directory-structure/app/composables#how-files-are-scanned
|
||
*/
|
||
dirs?: string[];
|
||
/**
|
||
* Enabled scan for local directories for auto imports.
|
||
* When this is disabled, `dirs` options will be ignored.
|
||
*/
|
||
scan?: boolean;
|
||
/**
|
||
* Assign auto imported utilities to `globalThis` instead of using built time transformation.
|
||
*/
|
||
global?: boolean;
|
||
transform?: {
|
||
exclude?: RegExp[];
|
||
include?: RegExp[];
|
||
};
|
||
/**
|
||
* Add polyfills for setInterval, requestIdleCallback, and others
|
||
*/
|
||
polyfills?: boolean;
|
||
/** Auto-imports to register. */
|
||
imports?: NuxtImport[];
|
||
/** Presets of auto-imports to register, either declared inline or named. */
|
||
presets?: (NuxtImportPresetSource | NuxtImportPresetName)[];
|
||
/** Options for scanning `dirs`. */
|
||
dirsScanOptions?: NuxtImportScanOptions;
|
||
/** Addons extending how auto-imports are injected. */
|
||
addons?: NuxtImportAddonsOptions | any[];
|
||
/**
|
||
* Virtual modules exposing every registered auto-import.
|
||
* @default ['#imports']
|
||
*/
|
||
virtualImports?: string[];
|
||
/** Resolve the module specifier an auto-import is imported from. */
|
||
resolveId?: (id: string, importee?: string) => string | void | Promise<string | void>;
|
||
/**
|
||
* Magic comments that opt a file out of auto-import injection.
|
||
* @default ['@unimport-disable', '@imports-disable']
|
||
*/
|
||
commentsDisable?: string[];
|
||
/**
|
||
* Magic comments that log auto-import injection for a file.
|
||
* @default ['@unimport-debug', '@imports-debug']
|
||
*/
|
||
commentsDebug?: string[];
|
||
/** Collect metadata for each auto-import. */
|
||
collectMeta?: boolean;
|
||
/** Inject imports at the end of the file rather than in place. */
|
||
injectAtEnd?: boolean;
|
||
/** Merge injected imports into existing import statements for the same module. */
|
||
mergeExisting?: boolean;
|
||
/** Parser used to detect identifiers in need of an auto-import. */
|
||
parser?: "acorn" | "oxc" | "regex";
|
||
/** Warn about auto-import conflicts and other recoverable problems. */
|
||
warn?: (message: string) => void;
|
||
/** Log auto-import injection details. */
|
||
debugLog?: (message: string) => void;
|
||
}
|
||
/**
|
||
* `SCREAMING_SNAKE_CASE` conversion at the type level, used to describe the environment variable
|
||
* that overrides each runtime config key.
|
||
*
|
||
* Nuxt owns this type so the string-casing implementation can change without changing the
|
||
* documented environment variable names. Kept deliberately close to `scule`'s `snakeCase`.
|
||
*/
|
||
type CaseSeparator = "-" | "_" | "/" | ".";
|
||
type FirstChar<S extends string> = S extends `${infer F}${string}` ? F : never;
|
||
type WithoutFirstChar<S extends string> = S extends `${string}${infer R}` ? R : never;
|
||
type IsUpper<S extends string> = S extends Uppercase<S> ? true : false;
|
||
type IsLower<S extends string> = S extends Lowercase<S> ? true : false;
|
||
type SameCase<X extends string, Y extends string> = IsUpper<X> extends IsUpper<Y> ? true : IsLower<X> extends IsLower<Y> ? true : false;
|
||
type LastOf<T extends any[]> = T extends [...any, infer R] ? R : never;
|
||
type WithoutLastOf<T extends any[]> = T extends [...infer F, any] ? F : never;
|
||
type JoinLowercaseWords<T extends readonly string[], Joiner extends string, Accumulator extends string = ""> = T extends readonly [infer F extends string, ...infer R extends string[]] ? Accumulator extends "" ? JoinLowercaseWords<R, Joiner, `${Accumulator}${Lowercase<F>}`> : JoinLowercaseWords<R, Joiner, `${Accumulator}${Joiner}${Lowercase<F>}`> : Accumulator;
|
||
type SplitByCase<T, Separator extends string = CaseSeparator, Accumulator extends unknown[] = []> = string extends Separator ? string[] : T extends `${infer F}${infer R}` ? [LastOf<Accumulator>] extends [never] ? SplitByCase<R, Separator, [F]> : LastOf<Accumulator> extends string ? R extends "" ? SplitByCase<R, Separator, [...WithoutLastOf<Accumulator>, `${LastOf<Accumulator>}${F}`]> : SameCase<F, FirstChar<R>> extends true ? F extends Separator ? FirstChar<R> extends Separator ? SplitByCase<R, Separator, [...Accumulator, ""]> : IsUpper<FirstChar<R>> extends true ? SplitByCase<WithoutFirstChar<R>, Separator, [...Accumulator, FirstChar<R>]> : SplitByCase<R, Separator, [...Accumulator, ""]> : SplitByCase<R, Separator, [...WithoutLastOf<Accumulator>, `${LastOf<Accumulator>}${F}`]> : IsLower<F> extends true ? SplitByCase<WithoutFirstChar<R>, Separator, [...WithoutLastOf<Accumulator>, `${LastOf<Accumulator>}${F}`, FirstChar<R>]> : SplitByCase<R, Separator, [...Accumulator, F]> : never : Accumulator extends [] ? T extends "" ? [] : string[] : Accumulator;
|
||
/** `snake_case` conversion at the type level. */
|
||
type SnakeCase<T extends string | readonly string[]> = string extends T ? string : string[] extends T ? string : T extends string ? SplitByCase<T> extends readonly string[] ? JoinLowercaseWords<SplitByCase<T>, "_"> : never : T extends readonly string[] ? JoinLowercaseWords<T, "_"> : never;
|
||
type RouterOptions$1 = Partial<Omit<RouterOptions, "history" | "routes">> & {
|
||
history?: (baseURL?: string) => RouterHistory | null | undefined;
|
||
routes?: (_routes: RouterOptions["routes"]) => RouterOptions["routes"] | Promise<RouterOptions["routes"]>;
|
||
hashMode?: boolean;
|
||
scrollBehaviorType?: "smooth" | "auto";
|
||
};
|
||
type RouterConfig = RouterOptions$1;
|
||
/**
|
||
* Only JSON serializable router options are configurable from nuxt config
|
||
*/
|
||
type RouterConfigSerializable = Pick<RouterConfig, "linkActiveClass" | "linkExactActiveClass" | "end" | "sensitive" | "strict" | "hashMode" | "scrollBehaviorType">;
|
||
/**
|
||
* Create a NuxtLink component with given options as defaults.
|
||
*
|
||
* Declared without reference to `vue-router`'s link types, which would otherwise force a
|
||
* (possibly duplicated) `vue-router` instance into every consuming program.
|
||
* @see https://nuxt.com/docs/4.x/api/components/nuxt-link
|
||
*/
|
||
interface NuxtLinkOptions {
|
||
/**
|
||
* The name of the component.
|
||
* @default "NuxtLink"
|
||
*/
|
||
componentName?: string;
|
||
/**
|
||
* A default `rel` attribute value applied on external links. Defaults to `"noopener noreferrer"`. Set it to `""` to disable.
|
||
*/
|
||
externalRelAttribute?: string | null;
|
||
/**
|
||
* An option to either add or remove trailing slashes in the `href`.
|
||
* If unset or not matching the valid values `append` or `remove`, it will be ignored.
|
||
*/
|
||
trailingSlash?: "append" | "remove";
|
||
/** A class to apply to active links. */
|
||
activeClass?: string;
|
||
/** A class to apply to exact active links. */
|
||
exactActiveClass?: string;
|
||
/** A class to apply to links that have been prefetched. */
|
||
prefetchedClass?: string;
|
||
/** When enabled will prefetch middleware, layouts and payloads of links in the viewport. */
|
||
prefetch?: boolean;
|
||
/**
|
||
* Allows controlling default setting for when to prefetch links. By default, prefetch is triggered only on visibility.
|
||
*/
|
||
prefetchOn?: Partial<{
|
||
visibility: boolean;
|
||
interaction: boolean;
|
||
}>;
|
||
}
|
||
type JavascriptExtension = "js" | "ts" | "tsx" | "jsx" | "mjs" | "cjs" | "mts" | "cts";
|
||
type VueExtension = "vue";
|
||
/**
|
||
* Allows adding additional types to a property of an object.
|
||
* If the property is an array, the type will be added to the array items.
|
||
*/
|
||
type AugmentProperty<T extends Record<string, any>, K extends keyof T, V> = { [key in keyof T]: key extends K ? NonNullable<T[key]> extends Array<infer U> ? (U | V)[] : T[key] : T[key]; };
|
||
interface KeyedFunction {
|
||
/**
|
||
* The name of the function.
|
||
*
|
||
* Use 'default' to target a module's default export. In that case, the callable name
|
||
* is derived from the filename (camel-cased) for matching during analysis.
|
||
*/
|
||
name: string;
|
||
/**
|
||
* The path to the file where the function is defined.
|
||
* You can use Nuxt aliases (~ or @) to refer to directories inside the project or directly use an npm package path similar to require.
|
||
*/
|
||
source: string;
|
||
/**
|
||
* The maximum number of arguments the function can accept.
|
||
* In the case that the function is called with fewer arguments than this number,
|
||
* the compiler will inject an auto-generated key as an additional argument.
|
||
*
|
||
* The key is unique based on the location of the function being invoked within the file.
|
||
*
|
||
* @example `{ name: 'useKey', source: '~/composables/useKey', argumentLength: 2 }`
|
||
*
|
||
* ```ts
|
||
* useKey() // will be transformed to: useKey('\$KzLSZ0O59L')
|
||
* useKey('first') // will be transformed to: useKey('first', '\$KzLSZ0O59L')
|
||
* useKey('first', 'second') // will not be transformed
|
||
* ```
|
||
*/
|
||
argumentLength: number;
|
||
}
|
||
interface KeyedFunctionFactory extends Pick<KeyedFunction, "argumentLength"> {
|
||
/**
|
||
* The name of the factory function.
|
||
* @example 'createUseFetch'
|
||
*/
|
||
name: string;
|
||
source: string;
|
||
}
|
||
interface NuxtCompilerOptions {
|
||
/**
|
||
* Enable scanning of directories for Nuxt compiler transformations.
|
||
*/
|
||
scan?: boolean;
|
||
}
|
||
interface CompilerScanDir {
|
||
/**
|
||
* Path (absolute or relative) to the directory to scan for files.
|
||
* Relative paths are resolved against the Nuxt source directory of the project.
|
||
*
|
||
* You can use Nuxt aliases (~ or @) to refer to directories inside the project or directly use an NPM package path similar to `require()`.
|
||
*/
|
||
path: string;
|
||
/**
|
||
* The file extensions to scan in the specified path.
|
||
*
|
||
* This has no effect if `pattern` is specified.
|
||
*/
|
||
extensions?: (JavascriptExtension | (string & {}))[];
|
||
/**
|
||
* Accept Pattern that will be run against the specified path.
|
||
*/
|
||
pattern?: string | string[];
|
||
/**
|
||
* Ignore patterns that will be run against the specified path.
|
||
*/
|
||
ignore?: string[];
|
||
}
|
||
interface ComponentMeta {
|
||
/**
|
||
* Short description shown as IDE hover documentation for the component.
|
||
*/
|
||
description?: string;
|
||
/**
|
||
* Documentation URL rendered as a `@see` tag in generated component types.
|
||
*/
|
||
docsUrl?: string;
|
||
[key: string]: unknown;
|
||
}
|
||
interface Component {
|
||
pascalName: string;
|
||
kebabName: string;
|
||
export: string;
|
||
filePath: string;
|
||
shortPath: string;
|
||
chunkName: string;
|
||
prefetch: boolean;
|
||
preload: boolean;
|
||
global?: boolean | "sync";
|
||
island?: boolean;
|
||
meta?: ComponentMeta;
|
||
mode?: "client" | "server" | "all";
|
||
/**
|
||
* This number allows configuring the behavior of overriding Nuxt components.
|
||
* If multiple components are provided with the same name, then higher priority
|
||
* components will be used instead of lower priority components.
|
||
*/
|
||
priority?: number;
|
||
/**
|
||
* Path to component's declaration file
|
||
* Used for type generation when different from filePath
|
||
* @default filePath
|
||
*/
|
||
declarationPath?: string;
|
||
/**
|
||
* Allow bypassing client/server transforms for internal Nuxt components like
|
||
* ServerPlaceholder and NuxtClientFallback.
|
||
*
|
||
* @internal
|
||
*/
|
||
_raw?: boolean;
|
||
}
|
||
interface ScanDir extends Omit<CompilerScanDir, "extensions"> {
|
||
/**
|
||
* Prefix all matched components.
|
||
*/
|
||
prefix?: string;
|
||
/**
|
||
* Prefix component name by its path.
|
||
*/
|
||
pathPrefix?: boolean;
|
||
/**
|
||
* These properties (prefetch/preload) are used in production to configure how components with Lazy prefix are handled by webpack via its magic comments.
|
||
* Learn more on webpack documentation: https://webpack.js.org/api/module-methods/#magic-comments
|
||
*/
|
||
prefetch?: boolean;
|
||
/**
|
||
* These properties (prefetch/preload) are used in production to configure how components with Lazy prefix are handled by webpack via its magic comments.
|
||
* Learn more on webpack documentation: https://webpack.js.org/api/module-methods/#magic-comments
|
||
*/
|
||
preload?: boolean;
|
||
/**
|
||
* This flag indicates, component should be loaded async (with a separate chunk) regardless of using Lazy prefix or not.
|
||
*/
|
||
isAsync?: boolean;
|
||
extendComponent?: (component: Component) => Promise<Component | void> | (Component | void);
|
||
/**
|
||
* If enabled, registers components to be globally available.
|
||
*
|
||
*/
|
||
global?: boolean;
|
||
/**
|
||
* If enabled, registers components as islands
|
||
*/
|
||
island?: boolean;
|
||
}
|
||
interface ComponentsDir extends ScanDir, AugmentProperty<Pick<CompilerScanDir, "extensions">, "extensions", VueExtension> {
|
||
/**
|
||
* Watch specified path for changes, including file additions and file deletions.
|
||
*/
|
||
watch?: boolean;
|
||
/**
|
||
* Transpile specified path using build.transpile.
|
||
* By default ('auto') it will set transpile: true if node_modules/ is in path.
|
||
*/
|
||
transpile?: "auto" | boolean;
|
||
/**
|
||
* This number allows configuring the behavior of overriding Nuxt components.
|
||
* It will be inherited by any components within the directory.
|
||
*
|
||
* If multiple components are provided with the same name, then higher priority
|
||
* components will be used instead of lower priority components.
|
||
*/
|
||
priority?: number;
|
||
}
|
||
interface ComponentsOptions {
|
||
dirs: (string | ComponentsDir)[];
|
||
/**
|
||
* The default value for whether to globally register components.
|
||
*
|
||
* When components are registered globally, they will still be directly imported where used,
|
||
* but they can also be used dynamically, for example `<component :is="`icon-${myIcon}`">`.
|
||
*
|
||
* This can be overridden by an individual component directory entry.
|
||
*/
|
||
global?: boolean;
|
||
/**
|
||
* Whether to write metadata to the build directory with information about the components that
|
||
* are auto-registered in your app.
|
||
*/
|
||
generateMetadata?: boolean;
|
||
loader?: boolean;
|
||
transform?: {
|
||
exclude?: RegExp[];
|
||
include?: RegExp[];
|
||
};
|
||
}
|
||
/** A single entry in the client build manifest. */
|
||
interface NuxtManifestResource {
|
||
/** Source module the chunk was built from. */
|
||
src?: string;
|
||
/** Emitted filename, relative to the build assets directory. */
|
||
file: string;
|
||
/** Stylesheets emitted alongside the chunk. */
|
||
css?: string[];
|
||
/** Other assets emitted alongside the chunk. */
|
||
assets?: string[];
|
||
isEntry?: boolean;
|
||
name?: string;
|
||
isDynamicEntry?: boolean;
|
||
sideEffects?: boolean;
|
||
imports?: string[];
|
||
dynamicImports?: string[];
|
||
/** Whether the resource is an ES module. */
|
||
module?: boolean;
|
||
/** Emit a `prefetch` resource hint for this resource. */
|
||
prefetch?: boolean;
|
||
/** Emit a `preload` resource hint for this resource. */
|
||
preload?: boolean;
|
||
resourceType?: "audio" | "document" | "embed" | "fetch" | "font" | "image" | "object" | "script" | "style" | "track" | "worker" | "video";
|
||
mimeType?: string;
|
||
}
|
||
/** The client build manifest, used to render resource hints and resolve module dependencies. */
|
||
interface NuxtManifest {
|
||
[key: string]: NuxtManifestResource;
|
||
}
|
||
/**
|
||
* Nuxt's hook registry surface, as exposed on `nuxt.hooks` and mirrored by `nuxt.hook()` and
|
||
* `nuxt.callHook()`.
|
||
*
|
||
* The types below describe the contract rather than the implementation, so the underlying hook
|
||
* library can be swapped without changing Nuxt's public API. They are structurally satisfied by
|
||
* `hookable`.
|
||
*/
|
||
type NuxtHookCallback = (...args: any) => Promise<void> | void;
|
||
type NuxtHookKeys<T> = keyof T & string;
|
||
interface NuxtDeprecatedHook<T> {
|
||
message?: string;
|
||
to: NuxtHookKeys<T>;
|
||
}
|
||
type ValueOf$1<T> = T extends Record<any, any> ? T[keyof T] : never;
|
||
type Strings<T> = Exclude<keyof T, number | symbol>;
|
||
type KnownKeys<T> = keyof { [K in keyof T as string extends K ? never : number extends K ? never : K]: never; };
|
||
type StripGeneric<T> = Pick<T, KnownKeys<T> extends keyof T ? KnownKeys<T> : never>;
|
||
type OnlyGeneric<T> = Omit<T, KnownKeys<T> extends keyof T ? KnownKeys<T> : never>;
|
||
type Namespaces<T> = ValueOf$1<{ [K in Strings<T>]: K extends `${infer Namespace}:${string}` ? Namespace : never; }>;
|
||
type BareHooks<T> = ValueOf$1<{ [K in Strings<T>]: K extends `${string}:${string}` ? never : K; }>;
|
||
type HooksInNamespace<T, Namespace extends string> = ValueOf$1<{ [K in Strings<T>]: K extends `${Namespace}:${infer HookName}` ? HookName : never; }>;
|
||
type WithoutNamespace<T, Namespace extends string> = { [K in HooksInNamespace<T, Namespace>]: `${Namespace}:${K}` extends keyof T ? T[`${Namespace}:${K}`] : never; };
|
||
/**
|
||
* Hooks as they may be written in `nuxt.config`, where a namespaced hook such as `build:done`
|
||
* can also be nested under a `build` key.
|
||
*/
|
||
type NuxtNestedHooks<T> = (Partial<StripGeneric<T>> | Partial<OnlyGeneric<T>>) & Partial<{ [K in Namespaces<StripGeneric<T>>]: NuxtNestedHooks<WithoutNamespace<T, K>>; }> & Partial<{ [K in BareHooks<StripGeneric<T>>]: T[K]; }>;
|
||
type InferCallback<HT, HN extends keyof HT> = HT[HN] extends NuxtHookCallback ? HT[HN] : never;
|
||
/** A hook call, as observed by `beforeEach` and `afterEach`. */
|
||
type NuxtHookSpyEvent<HT extends Record<string, any>> = { [K in keyof HT]: {
|
||
name: K;
|
||
args: Parameters<HT[K]>;
|
||
context: Record<string, any>;
|
||
}; }[keyof HT];
|
||
interface NuxtHookRegistry<HooksT extends Record<string, any>, HookNameT extends NuxtHookKeys<HooksT> = NuxtHookKeys<HooksT>> {
|
||
/** Register a listener for a hook. Returns a function that removes it again. */
|
||
hook: <NameT extends HookNameT>(name: NameT, fn: InferCallback<HooksT, NameT>, options?: {
|
||
allowDeprecated?: boolean;
|
||
}) => () => void;
|
||
/** Register a listener that is removed after it runs once. */
|
||
hookOnce: <NameT extends HookNameT>(name: NameT, fn: InferCallback<HooksT, NameT>) => () => void;
|
||
removeHook: <NameT extends HookNameT>(name: NameT, fn: InferCallback<HooksT, NameT>) => void;
|
||
/** Remove every listener for a hook. */
|
||
clearHook: <NameT extends HookNameT>(name: NameT) => void;
|
||
/** Mark a hook as deprecated in favour of another. */
|
||
deprecateHook: <NameT extends HookNameT>(name: NameT, deprecated: NuxtHookKeys<HooksT> | NuxtDeprecatedHook<HooksT>) => void;
|
||
deprecateHooks: (deprecatedHooks: Partial<Record<HookNameT, NuxtDeprecatedHook<HooksT>>>) => void;
|
||
/** Register several listeners at once, optionally nested by namespace. */
|
||
addHooks: (configHooks: NuxtNestedHooks<HooksT>) => () => void;
|
||
removeHooks: (configHooks: NuxtNestedHooks<HooksT>) => void;
|
||
removeAllHooks: () => void;
|
||
/** Call every listener for a hook in series. */
|
||
callHook: <NameT extends HookNameT>(name: NameT, ...args: Parameters<InferCallback<HooksT, NameT>>) => Promise<any> | void;
|
||
/** Call every listener for a hook in parallel. */
|
||
callHookParallel: <NameT extends HookNameT>(name: NameT, ...args: Parameters<InferCallback<HooksT, NameT>>) => Promise<any[]> | void;
|
||
/** Call every listener for a hook through a custom caller. */
|
||
callHookWith: <NameT extends HookNameT, CallFunction extends (hooks: NuxtHookCallback[], args: Parameters<InferCallback<HooksT, NameT>>, name: NameT) => any>(caller: CallFunction, name: NameT, args: Parameters<InferCallback<HooksT, NameT>>) => ReturnType<CallFunction>;
|
||
/** Observe every hook call before its listeners run. */
|
||
beforeEach: (fn: (event: NuxtHookSpyEvent<HooksT>) => void) => () => void;
|
||
/** Observe every hook call after its listeners have run. */
|
||
afterEach: (fn: (event: NuxtHookSpyEvent<HooksT>) => void) => () => void;
|
||
}
|
||
/** Options for the gitignore-style matcher Nuxt uses to ignore files. */
|
||
interface NuxtIgnoreOptions {
|
||
/** Match patterns case-insensitively. */
|
||
ignorecase?: boolean;
|
||
/** Alias of `ignorecase`. */
|
||
ignoreCase?: boolean;
|
||
/** Allow paths that are not relative to the project root to be tested. */
|
||
allowRelativePaths?: boolean;
|
||
}
|
||
/** The result of testing a path against the ignore rules. */
|
||
interface NuxtIgnoreTestResult {
|
||
ignored: boolean;
|
||
unignored: boolean;
|
||
rule?: unknown;
|
||
}
|
||
/**
|
||
* A compiled set of gitignore-style rules, built from `.nuxtignore`, `.gitignore` and the
|
||
* `ignore` option.
|
||
*/
|
||
interface NuxtIgnoreMatcher {
|
||
/**
|
||
* Add one or more patterns to the matcher.
|
||
*
|
||
* Declared with method syntax so implementations may accept a wider set of inputs.
|
||
*/
|
||
add(patterns: string | readonly string[]): NuxtIgnoreMatcher;
|
||
/** Whether the given project-relative path should be ignored. */
|
||
ignores: (pathname: string) => boolean;
|
||
/** Filter project-relative paths, keeping those that are not ignored. */
|
||
filter: (pathnames: readonly string[]) => string[];
|
||
/** Create a predicate suitable for `Array.prototype.filter`. */
|
||
createFilter: () => (pathname: string) => boolean;
|
||
/** Test a path, reporting whether a rule ignored or explicitly unignored it. */
|
||
test: (pathname: string) => NuxtIgnoreTestResult;
|
||
}
|
||
/**
|
||
* The result of merging module options over their defaults, as `defineNuxtModule` does.
|
||
*
|
||
* Nuxt owns this type so that the merge implementation can change without changing the shape
|
||
* modules see. Kept deliberately close to `defu`'s semantics: objects merge recursively, arrays
|
||
* concatenate, and nullish values fall through to the default.
|
||
*/
|
||
type MergeInput = Record<string | number | symbol, any>;
|
||
type IgnoredMergeInput = boolean | number | null | any[] | Record<never, any> | undefined;
|
||
type Nullish = null | undefined | void;
|
||
type MergeArrays<Destination, Source> = Destination extends Array<infer DestinationType> ? Source extends Array<infer SourceType> ? Array<DestinationType | SourceType> : Source | Array<DestinationType> : Source | Destination;
|
||
type MergeObjects<Destination extends MergeInput, Defaults extends MergeInput> = Destination extends Defaults ? Destination : Omit<Destination, keyof Destination & keyof Defaults> & Omit<Defaults, keyof Destination & keyof Defaults> & { -readonly [Key in keyof Destination & keyof Defaults]: Destination[Key] extends Nullish ? Defaults[Key] extends Nullish ? Nullish : Defaults[Key] : Defaults[Key] extends Nullish ? Destination[Key] : MergeValues<Destination[Key], Defaults[Key]>; };
|
||
type MergeValues<Destination extends MergeInput, Defaults extends MergeInput> = Destination extends Nullish ? Defaults extends Nullish ? Nullish : Defaults : Defaults extends Nullish ? Destination : Destination extends Array<any> ? Defaults extends Array<any> ? MergeArrays<Destination, Defaults> : Destination | Defaults : Destination extends Function | RegExp | Promise<any> ? Destination | Defaults : Defaults extends Function | RegExp | Promise<any> ? Destination | Defaults : Destination extends MergeInput ? Defaults extends MergeInput ? MergeObjects<Destination, Defaults> : Destination | Defaults : Destination | Defaults;
|
||
/** Merge `Source` over each entry of `Defaults`, left to right. */
|
||
type Merged<Source extends MergeInput, Defaults extends Array<MergeInput | IgnoredMergeInput>> = Defaults extends [infer First, ...infer Rest] ? First extends MergeInput ? Rest extends Array<MergeInput | IgnoredMergeInput> ? Merged<MergeObjects<Source, First>, Rest> : MergeObjects<Source, First> : First extends IgnoredMergeInput ? Rest extends Array<MergeInput | IgnoredMergeInput> ? Merged<Source, Rest> : Source : Source : Source;
|
||
interface ModuleMeta {
|
||
/** Module name. */
|
||
name?: string;
|
||
/** Module version. */
|
||
version?: string;
|
||
/**
|
||
* The configuration key used within `nuxt.config` for this module's options.
|
||
* For example, `@nuxtjs/axios` uses `axios`.
|
||
*/
|
||
configKey?: string;
|
||
/**
|
||
* Constraints for the versions of Nuxt or features this module requires.
|
||
*/
|
||
compatibility?: NuxtCompatibility;
|
||
/**
|
||
* Fully resolved path used internally by Nuxt. Do not depend on this value.
|
||
* @internal
|
||
*/
|
||
rawPath?: string;
|
||
/**
|
||
* Whether the module has been disabled in the Nuxt configuration.
|
||
* @internal
|
||
*/
|
||
disabled?: boolean;
|
||
[key: string]: unknown;
|
||
}
|
||
/** The options received. */
|
||
type ModuleOptions = Record<string, any>;
|
||
type ModuleSetupInstallResult = {
|
||
/**
|
||
* Timing information for the initial setup
|
||
*/
|
||
timings?: {
|
||
/** Total time took for module setup in ms */
|
||
setup?: number;
|
||
[key: string]: number | undefined;
|
||
};
|
||
};
|
||
type Awaitable<T> = T | Promise<T>;
|
||
type Prettify<T> = { [K in keyof T]: T[K]; } & {};
|
||
type ModuleSetupReturn = Awaitable<false | void | ModuleSetupInstallResult>;
|
||
type ResolvedModuleOptions<TOptions extends ModuleOptions, TOptionsDefaults extends Partial<TOptions>> = Prettify<Merged<Partial<TOptions>, [Partial<TOptions>, TOptionsDefaults]>>;
|
||
interface ModuleDependencyMeta<T = Record<string, unknown>> {
|
||
version?: string;
|
||
overrides?: Partial<T>;
|
||
defaults?: Partial<T>;
|
||
optional?: boolean;
|
||
}
|
||
interface ModuleDependencies {
|
||
[key: string]: ModuleDependencyMeta<Record<string, unknown>>;
|
||
}
|
||
/** Module definition passed to 'defineNuxtModule(...)' or 'defineNuxtModule().with(...)'. */
|
||
interface ModuleDefinition<TOptions extends ModuleOptions, TOptionsDefaults extends Partial<TOptions>, TWith extends boolean> {
|
||
meta?: ModuleMeta;
|
||
defaults?: TOptionsDefaults | ((nuxt: Nuxt) => Awaitable<TOptionsDefaults>);
|
||
schema?: TOptions;
|
||
hooks?: Partial<NuxtHooks>;
|
||
moduleDependencies?: ModuleDependencies | ((nuxt: Nuxt) => Awaitable<ModuleDependencies>);
|
||
onInstall?: (nuxt: Nuxt) => Awaitable<void>;
|
||
onUpgrade?: (nuxt: Nuxt, options: TOptions, previousVersion: string) => Awaitable<void>;
|
||
setup?: (this: void, resolvedOptions: TWith extends true ? ResolvedModuleOptions<TOptions, TOptionsDefaults> : TOptions, nuxt: Nuxt) => ModuleSetupReturn;
|
||
}
|
||
interface NuxtModule<TOptions extends ModuleOptions = ModuleOptions, TOptionsDefaults extends Partial<TOptions> = Partial<TOptions>, TWith extends boolean = false> {
|
||
(this: void, resolvedOptions: TWith extends true ? ResolvedModuleOptions<TOptions, TOptionsDefaults> : TOptions, nuxt: Nuxt): ModuleSetupReturn;
|
||
getOptions?: (inlineOptions?: Partial<TOptions>, nuxt?: Nuxt) => Promise<TWith extends true ? ResolvedModuleOptions<TOptions, TOptionsDefaults> : TOptions>;
|
||
getModuleDependencies?: (nuxt: Nuxt) => Awaitable<ModuleDependencies> | undefined;
|
||
getMeta?: () => Promise<ModuleMeta>;
|
||
onInstall?: (nuxt: Nuxt) => Awaitable<void>;
|
||
onUpgrade?: (nuxt: Nuxt, options: TWith extends true ? ResolvedModuleOptions<TOptions, TOptionsDefaults> : TOptions, previousVersion: string) => Awaitable<void>;
|
||
}
|
||
interface NuxtDebugContext {
|
||
/**
|
||
* Module mutation records to the `nuxt` instance.
|
||
*/
|
||
moduleMutationRecords?: NuxtDebugModuleMutationRecord[];
|
||
}
|
||
interface NuxtDebugModuleMutationRecord {
|
||
module: NuxtModule;
|
||
keys: (string | symbol)[];
|
||
target: "nuxt.options";
|
||
value: any;
|
||
method?: string;
|
||
timestamp: number;
|
||
}
|
||
interface NuxtDebugOptions {
|
||
/** Debug for Nuxt templates */
|
||
templates?: boolean;
|
||
/** Debug for modules setup timings */
|
||
modules?: boolean;
|
||
/** Debug for file watchers */
|
||
watchers?: boolean;
|
||
/** Debug for production hydration mismatch */
|
||
hydration?: boolean;
|
||
/** Debug for Vue Router */
|
||
router?: boolean;
|
||
/** Debug for hooks, can be set to `true` or an object with `server` and `client` keys */
|
||
hooks?: boolean | {
|
||
server?: boolean;
|
||
client?: boolean;
|
||
};
|
||
/**
|
||
* Profile startup/build performance.
|
||
*
|
||
* - `true` — full report printed to console, JSON + `.cpuprofile` written on exit
|
||
* - `'quiet'` — JSON + `.cpuprofile` written on exit with no console output
|
||
*
|
||
* Activated via `nuxt dev --profile=verbose`, `nuxt dev --profile` (quiet),
|
||
* `NUXT_DEBUG_PERF=1` (or `=quiet`), or `debug: { perf: true }` in nuxt.config.
|
||
* @since 4.4.0
|
||
*/
|
||
perf?: boolean | "quiet";
|
||
/**
|
||
* Debug options for Nitro.
|
||
*/
|
||
nitro?: boolean;
|
||
}
|
||
interface NuxtPlugin {
|
||
/** @deprecated use mode */
|
||
ssr?: boolean;
|
||
src: string;
|
||
mode?: "all" | "server" | "client";
|
||
/**
|
||
* This allows more granular control over plugin order and should only be used by advanced users.
|
||
* Lower numbers run first, and user plugins default to `0`.
|
||
*
|
||
* Default Nuxt priorities can be seen at [here](https://github.com/nuxt/nuxt/blob/9904849bc87c53dfbd3ea3528140a5684c63c8d8/packages/nuxt/src/core/plugins/plugin-metadata.ts#L15-L34).
|
||
*/
|
||
order?: number;
|
||
/**
|
||
* @internal
|
||
*/
|
||
name?: string;
|
||
}
|
||
type TemplateDefaultOptions = Record<string, any>;
|
||
/**
|
||
* A well-known input a template can declare it depends on:
|
||
*
|
||
* - `'pages'`: the contents of the files backing `app.pages`
|
||
* - `'plugins'`: the contents of the files listed in `app.plugins`
|
||
*/
|
||
type NuxtTemplateDependency = "pages" | "plugins";
|
||
/** A watched file event that may require regenerating templates. */
|
||
interface NuxtTemplateChange {
|
||
event: WatchEvent;
|
||
/** absolute path of the file the event was emitted for */
|
||
path: string;
|
||
}
|
||
interface NuxtTemplate<Options = TemplateDefaultOptions> {
|
||
/** resolved output file path (generated) */
|
||
dst?: string;
|
||
/** The target filename once the template is copied into the Nuxt buildDir */
|
||
filename?: string;
|
||
/** An options object that will be accessible within the template via `<% options %>` */
|
||
options?: Options;
|
||
/** The resolved path to the source file to be template */
|
||
src?: string;
|
||
/** Provided compile option instead of src */
|
||
getContents?: (data: {
|
||
nuxt: Nuxt;
|
||
app: NuxtApp;
|
||
options: Options;
|
||
}) => string | Promise<string>;
|
||
/** Write to filesystem */
|
||
write?: boolean;
|
||
/**
|
||
* The watched inputs the output of this template can depend on, beyond `nuxt.options` and the
|
||
* resolved structure of the app (which files exist, and where).
|
||
*
|
||
* Set this to `[]` if the template never reads the contents of a watched file. In dev mode
|
||
* Nuxt then skips recompiling it when a file changes without any file being added or removed.
|
||
* List well-known keys (such as `'pages'` or `'plugins'`) if the template reads those sources,
|
||
* or pass a function to decide per change.
|
||
*
|
||
* A template that declares nothing is regenerated on every change, unless it has a `src`, in
|
||
* which case it is regenerated only when that source file changes.
|
||
*/
|
||
dependsOn?: NuxtTemplateDependency[] | ((change: NuxtTemplateChange, ctx: {
|
||
nuxt: Nuxt;
|
||
app: NuxtApp;
|
||
options: Options;
|
||
}) => boolean);
|
||
/**
|
||
* The source path of the template (to try resolving dependencies from).
|
||
* @internal
|
||
*/
|
||
_path?: string;
|
||
}
|
||
interface NuxtServerTemplate {
|
||
/** The target filename once the template is copied into the Nuxt buildDir */
|
||
filename: string;
|
||
getContents: () => string | Promise<string>;
|
||
}
|
||
interface ResolvedNuxtTemplate<Options = TemplateDefaultOptions> extends NuxtTemplate<Options> {
|
||
filename: string;
|
||
dst: string;
|
||
modified?: boolean;
|
||
}
|
||
interface NuxtTypeTemplate<Options = TemplateDefaultOptions> extends Omit<NuxtTemplate<Options>, "write" | "filename"> {
|
||
filename: `${string}.d.ts`;
|
||
write?: true;
|
||
}
|
||
type _TemplatePlugin<Options> = Omit<NuxtPlugin, "src"> & NuxtTemplate<Options>;
|
||
interface NuxtPluginTemplate<Options = TemplateDefaultOptions> extends _TemplatePlugin<Options> {}
|
||
interface NuxtApp {
|
||
mainComponent?: string | null;
|
||
rootComponent?: string | null;
|
||
errorComponent?: string | null;
|
||
dir: string;
|
||
extensions: string[];
|
||
plugins: NuxtPlugin[];
|
||
components: Component[];
|
||
layouts: Record<string, NuxtLayout>;
|
||
middleware: NuxtMiddleware[];
|
||
templates: NuxtTemplate[];
|
||
configs: string[];
|
||
pages?: NuxtPage[];
|
||
}
|
||
/**
|
||
* Build artifacts consumed by the Nitro server runtime via `nuxt/*` subpath imports.
|
||
*
|
||
* Builders populate this with the `setBuildOutput()` kit helper. Each key is a
|
||
* (possibly async) function returning the module body as a string.
|
||
*/
|
||
interface NuxtBuildOutputs {
|
||
/** Module body re-exporting the SSR app entry. */
|
||
serverEntry: () => string | Promise<string>;
|
||
/**
|
||
* Module body for the per-component SSR styles map, plus an `inlinedCSS`
|
||
* named export mapping each emitted CSS file whose `<link>` may be dropped at
|
||
* render time to the groups of module IDs that inline its contents. Defaults
|
||
* to an empty map for both.
|
||
*/
|
||
ssrStyles: () => string | Promise<string>;
|
||
/** Serialized client manifest for `vue-bundle-renderer`. */
|
||
clientManifest: () => string | Promise<string>;
|
||
/** Serialized precomputed client dependency data for `vue-bundle-renderer`. */
|
||
clientPrecomputed: () => string | Promise<string>;
|
||
/** Module body exporting the hashed entry chunk filename for import maps. */
|
||
entryChunkName: () => string | Promise<string>;
|
||
/** Module body exporting the entry module IDs used for inline style extraction. */
|
||
entryIds: () => string | Promise<string>;
|
||
}
|
||
/**
|
||
* Where the configured server builder writes its output.
|
||
*
|
||
* Every path is a function rather than a string because a builder may only know its
|
||
* paths once it has initialised: Nitro's output directory depends on the resolved
|
||
* preset, and can still move afterwards. Call these from a hook that runs after `ready`.
|
||
*
|
||
* @internal
|
||
*/
|
||
interface NuxtServerBuildOutput {
|
||
/**
|
||
* Absolute path to the root of the project the build belongs to, without a trailing
|
||
* slash: where a deploy target's own configuration file lives and what the paths in it
|
||
* are written relative to.
|
||
*
|
||
* This is the project root rather than a bundler's notion of a root, which need not be
|
||
* the same directory: Nuxt points Vite's `root` at `srcDir`, so a target resolving its
|
||
* configuration from there looks in the wrong place.
|
||
*/
|
||
root: () => string;
|
||
/** Absolute path to the build output directory, without a trailing slash. */
|
||
dir: () => string;
|
||
/**
|
||
* Absolute path to the directory of deployable static assets within the output,
|
||
* without a trailing slash.
|
||
*/
|
||
publicDir: () => string;
|
||
}
|
||
/**
|
||
* Where the app builder leaves the artifacts a server build consumes, for a server builder
|
||
* that bundles or serves them from disk rather than through the `nuxt/*` module bodies of
|
||
* {@link NuxtBuildOutputs}.
|
||
*
|
||
* Paths are functions because the app builder may only know them once its configuration is
|
||
* resolved.
|
||
*
|
||
* @internal
|
||
*/
|
||
interface NuxtServerBuildInput {
|
||
/** Absolute path to the SSR entry the app builder emits, the input of a server bundle. */
|
||
serverEntry: () => string;
|
||
/** Absolute path to the directory the SSR build's chunks land in. */
|
||
serverDir: () => string;
|
||
/** Absolute path to the directory the client build's assets land in. */
|
||
clientDir: () => string;
|
||
/** Absolute path to the client manifest `vue-bundle-renderer` renders against. */
|
||
clientManifest: () => string;
|
||
}
|
||
/**
|
||
* What a server builder can do, so consumers need not infer it from its name.
|
||
*
|
||
* @internal
|
||
*/
|
||
interface NuxtServerBuildCapabilities {
|
||
/** Whether the build produces a server runtime. `false` for a static-only build. */
|
||
server: boolean;
|
||
/** Whether the builder provides a dev server on `nuxt.server`. */
|
||
dev: boolean;
|
||
}
|
||
/**
|
||
* Module specifiers the server build resolves its runtime from. A server builder that is
|
||
* not backed by Nitro points these at its own implementations.
|
||
*
|
||
* @internal
|
||
*/
|
||
interface NuxtServerBuildRuntime {
|
||
/**
|
||
* Exports `fetch`, used to back `$fetch` on the server. Omitted by a runtime that installs
|
||
* its own `$fetch` on `globalThis` rather than exposing a module to import from.
|
||
*/
|
||
fetch?: string;
|
||
/** Exports `useRuntimeConfig`. */
|
||
runtimeConfig: string;
|
||
/**
|
||
* Exports the implementations backing `nuxt/server`, which the server build resolves that
|
||
* subpath to. Omitted by a runtime with nothing to add to the web-standard implementations
|
||
* Nuxt ships, which the subpath resolves to otherwise.
|
||
*
|
||
* Every value `nuxt/server` exports must be exported here too: the types come from the
|
||
* `nuxt` package either way, so a missing export is a runtime error, not a type error.
|
||
*/
|
||
server?: string;
|
||
/**
|
||
* Exports `fetch`, a web-standard handler serving the built application, for a deploy
|
||
* target that runs the build in a worker or on a platform that hands it a `Request`. Only
|
||
* resolvable once the build producing it has run, and omitted by a runtime whose output is
|
||
* not importable as a module.
|
||
*/
|
||
handler?: string;
|
||
}
|
||
/**
|
||
* How to preview the build output locally.
|
||
*
|
||
* @internal
|
||
*/
|
||
interface NuxtServerBuildPreview {
|
||
/** Shell command that starts the built server, when there is one to start. */
|
||
command?: () => string | undefined;
|
||
/** Directory to serve statically when there is no server to start. */
|
||
staticDir?: () => string;
|
||
}
|
||
/**
|
||
* A description of the build the configured `server.builder` produces, for consumers
|
||
* (the Nuxt CLI, deployment tooling) that need to know what was built and where without
|
||
* reaching for a Nitro instance.
|
||
*
|
||
* **Experimental and not public API.** The shape is exported from `@nuxt/schema/internal`
|
||
* and read and written with the `useServerBuild()` / `setServerBuild()` helpers from
|
||
* `@nuxt/kit/internal`, and will change without a major release while the second server
|
||
* builder (`@nuxt/vite-server`) is being built out.
|
||
*
|
||
* @internal
|
||
*/
|
||
interface NuxtServerBuild {
|
||
/**
|
||
* Stable identifier for the builder implementation, such as `nitro` or `vite`.
|
||
* Defaults to the configured `server.builder` specifier.
|
||
*/
|
||
name: string;
|
||
/** Human-readable name of the builder, for CLI output. Defaults to `name`. */
|
||
label?: string;
|
||
/**
|
||
* Deploy target within the builder: a Nitro preset, or a Vite deploy target. Read on
|
||
* access, as a builder may resolve it during its own initialisation.
|
||
*/
|
||
target?: () => string | undefined;
|
||
/** What to call the `target` axis when printing it, such as `preset`. */
|
||
targetLabel?: string;
|
||
/**
|
||
* Whether the server build is a pass of its own, run by the server builder, rather than
|
||
* an environment of the app builder's build. A builder that builds separately also hosts
|
||
* the dev server, and reads the client manifest from disk rather than from the app
|
||
* builder's own build.
|
||
*/
|
||
buildsSeparately: boolean;
|
||
input: NuxtServerBuildInput;
|
||
output: NuxtServerBuildOutput;
|
||
capabilities: NuxtServerBuildCapabilities;
|
||
runtime: NuxtServerBuildRuntime;
|
||
preview?: NuxtServerBuildPreview;
|
||
}
|
||
interface Nuxt {
|
||
"__name": string;
|
||
"_version": string;
|
||
"_ignore"?: NuxtIgnoreMatcher;
|
||
"_dependencies"?: Set<string>;
|
||
"~runtimeDependencies"?: string[];
|
||
"_debug"?: NuxtDebugContext;
|
||
/**
|
||
* Performance profiler instance, available when `debug.perf` is enabled.
|
||
* @internal
|
||
*/
|
||
"_perf"?: {
|
||
startPhase: (name: string) => void;
|
||
endPhase: (name?: string) => void;
|
||
collectModuleTimings: (modules: Array<{
|
||
meta?: {
|
||
name?: string;
|
||
};
|
||
timings?: Record<string, number | undefined>;
|
||
}>) => void;
|
||
recordBundlerPluginHook: (pluginName: string, hookName: string, durationMs: number, startTime?: number) => void;
|
||
printReport: (options?: {
|
||
title?: string;
|
||
}) => void;
|
||
writeReport: (buildDir: string, options?: {
|
||
quiet?: boolean;
|
||
}) => string;
|
||
dispose: () => void;
|
||
};
|
||
/** Async local storage for current running Nuxt module instance. */
|
||
"_asyncLocalStorageModule"?: AsyncLocalStorage<NuxtModule>;
|
||
/**
|
||
* The Node HTTP(S) server the dev server is listening on, captured from the
|
||
* `listen` hook. Builders use it to attach their HMR websocket to the same
|
||
* server (and therefore the same port and certificate) as the app.
|
||
* @internal
|
||
*/
|
||
"_devServerListener"?: import("node:http").Server | import("node:https").Server;
|
||
/**
|
||
* Names of the bundler environments that build the app for the server, beyond `ssr`.
|
||
* Plugins registered with `addVitePlugin()` apply to these too, so that an environment a
|
||
* deploy target owns can bundle the app. Registered by the server builder, which is the
|
||
* only place that knows whether a server environment renders or is a runtime of its own
|
||
* (as Nitro's is).
|
||
* @internal
|
||
*/
|
||
"_appServerEnvironments"?: Set<string>;
|
||
/**
|
||
* Module options functions collected from moduleDependencies.
|
||
* @internal
|
||
*/
|
||
"_moduleOptionsFunctions"?: Map<string | NuxtModule, Array<() => {
|
||
defaults?: Record<string, unknown>;
|
||
overrides?: Record<string, unknown>;
|
||
}>>;
|
||
/** The resolved Nuxt configuration. */
|
||
"options": NuxtOptions;
|
||
"hooks": NuxtHookRegistry<NuxtHooks>;
|
||
"hook": Nuxt["hooks"]["hook"];
|
||
"callHook": Nuxt["hooks"]["callHook"];
|
||
"addHooks": Nuxt["hooks"]["addHooks"];
|
||
"runWithContext": <T extends (...args: any[]) => any>(fn: T) => ReturnType<T>;
|
||
"ready": () => Promise<void>;
|
||
"close": () => Promise<void>;
|
||
/** The production or development server. */
|
||
"server"?: any;
|
||
"vfs": Record<string, string>;
|
||
"apps": Record<string, NuxtApp>;
|
||
"buildOutputs": NuxtBuildOutputs;
|
||
/**
|
||
* A description of the build the configured server builder produces.
|
||
*
|
||
* @internal
|
||
*/
|
||
"serverBuild": NuxtServerBuild;
|
||
}
|
||
type HookResult = Promise<void> | void;
|
||
type TSReference = {
|
||
types: string;
|
||
} | {
|
||
path: string;
|
||
};
|
||
type WatchEvent = "add" | "addDir" | "change" | "unlink" | "unlinkDir";
|
||
type VueTSConfig = 0 extends 1 & RawVueCompilerOptions ? TSConfig : TSConfig & {
|
||
vueCompilerOptions?: RawVueCompilerOptions;
|
||
};
|
||
interface NuxtPageMeta {
|
||
[key: PropertyKey]: unknown;
|
||
}
|
||
interface NuxtPage {
|
||
name?: string;
|
||
path: string;
|
||
props?: RouteRecordRaw["props"];
|
||
file?: string;
|
||
/**
|
||
* Named view files keyed by view name, including `default`. Populated by the
|
||
* page scanner from the `name@view.vue` filename convention. When set, the
|
||
* keys are wired up to vue-router's [`components`](https://router.vuejs.org/guide/essentials/named-views.html)
|
||
* option so multiple `<NuxtPage name="..." />` outlets can render.
|
||
*/
|
||
components?: Record<string, string>;
|
||
meta?: NuxtPageMeta;
|
||
alias?: string[] | string;
|
||
redirect?: RouteLocationRaw;
|
||
children?: NuxtPage[];
|
||
middleware?: string[] | string;
|
||
/**
|
||
* Set the render mode.
|
||
*
|
||
* `all` means the page will be rendered isomorphically - with JavaScript both on client and server.
|
||
*
|
||
* `server` means pages are automatically rendered with server components, so there will be no JavaScript to render the page in your client bundle.
|
||
*
|
||
* `client` means that page will render on the client-side only.
|
||
*/
|
||
mode?: "client" | "server" | "all";
|
||
/** Route rules for the route this page is served at, as declared with `defineRouteRules()`. */
|
||
rules?: RouteRuleConfig;
|
||
/** @internal */
|
||
_sync?: boolean;
|
||
}
|
||
type NuxtMiddleware = {
|
||
name: string;
|
||
path: string;
|
||
global?: boolean;
|
||
};
|
||
type NuxtLayout = {
|
||
name: string;
|
||
file: string;
|
||
};
|
||
/**
|
||
* @deprecated Use {@link NuxtImportPreset}
|
||
*/
|
||
interface ImportPresetWithDeprecation extends NuxtImportPreset {}
|
||
interface ModuleInstallInfo {
|
||
/** A human-readable name for the module: `meta.name` where available, otherwise the package name, a path relative to `rootDir`, or the function name */
|
||
name: string;
|
||
meta: ModuleMeta;
|
||
/** The resolved path of the module on disk, where it is not an inline function */
|
||
path?: string;
|
||
}
|
||
interface GenerateAppOptions {
|
||
filter?: (template: ResolvedNuxtTemplate<any>) => boolean;
|
||
}
|
||
interface NuxtAnalyzeMeta {
|
||
name: string;
|
||
slug: string;
|
||
startTime: number;
|
||
endTime: number;
|
||
analyzeDir: string;
|
||
buildDir: string;
|
||
outDir: string;
|
||
}
|
||
/**
|
||
* The listeners to Nuxt build time events
|
||
*/
|
||
interface NuxtHooks {
|
||
/**
|
||
* Allows extending compatibility checks.
|
||
* @param compatibility Compatibility object
|
||
* @param issues Issues to be mapped
|
||
* @returns Promise
|
||
*/
|
||
"kit:compatibility": (compatibility: NuxtCompatibility, issues: NuxtCompatibilityIssues) => HookResult;
|
||
/**
|
||
* Called after Nuxt initialization, when the Nuxt instance is ready to work.
|
||
* @param nuxt The configured Nuxt object
|
||
* @returns Promise
|
||
*/
|
||
"ready": (nuxt: Nuxt) => HookResult;
|
||
/**
|
||
* Called when Nuxt instance is gracefully closing.
|
||
* @param nuxt The configured Nuxt object
|
||
* @returns Promise
|
||
*/
|
||
"close": (nuxt: Nuxt) => HookResult;
|
||
/**
|
||
* Called to restart the current Nuxt instance.
|
||
* @returns Promise
|
||
*/
|
||
"restart": (options?: {
|
||
/**
|
||
* Try to restart the whole process if supported
|
||
*/
|
||
hard?: boolean;
|
||
}) => HookResult;
|
||
/**
|
||
* Called during Nuxt initialization, before installing user modules.
|
||
* @returns Promise
|
||
*/
|
||
"modules:before": () => HookResult;
|
||
/**
|
||
* Called during Nuxt initialization, after installing user modules.
|
||
* @returns Promise
|
||
*/
|
||
"modules:done": () => HookResult;
|
||
/**
|
||
* Called immediately before each individual module is set up.
|
||
* @param module Information about the module about to be set up
|
||
* @returns Promise
|
||
*/
|
||
"module:before": (module: ModuleInstallInfo) => HookResult;
|
||
/**
|
||
* Called immediately after each individual module has been set up.
|
||
* @param module Information about the module that was set up, including how long it took
|
||
* @returns Promise
|
||
*/
|
||
"module:done": (module: ModuleInstallInfo & {
|
||
/** The module entry path, if it could be resolved */
|
||
entryPath?: string;
|
||
/**
|
||
* Timings for the module, in milliseconds. `setup` is how long the module took to set up; a module may report
|
||
* additional keys of its own. This is the same object recorded in `_installedModules`.
|
||
*/
|
||
timings: {
|
||
setup: number;
|
||
} & Record<string, number | undefined>;
|
||
}) => HookResult;
|
||
/**
|
||
* Called after resolving the `app` instance.
|
||
* @param app The resolved `NuxtApp` object
|
||
* @returns Promise
|
||
*/
|
||
"app:resolve": (app: NuxtApp) => HookResult;
|
||
/**
|
||
* Called during `NuxtApp` generation, to allow customizing, modifying or adding new files to the build directory (either virtually or to written to `.nuxt`).
|
||
* @param app The configured `NuxtApp` object
|
||
* @returns Promise
|
||
*/
|
||
"app:templates": (app: NuxtApp) => HookResult;
|
||
/**
|
||
* Called after templates are compiled into the [virtual file system](https://nuxt.com/docs/4.x/directory-structure/nuxt) (vfs).
|
||
* @param app The configured `NuxtApp` object
|
||
* @returns Promise
|
||
*/
|
||
"app:templatesGenerated": (app: NuxtApp, templates: ResolvedNuxtTemplate[], options?: GenerateAppOptions) => HookResult;
|
||
/**
|
||
* Called when Nuxt needs the full set of route handlers the server will serve, so that it can
|
||
* type `$fetch` and `useFetch` against them. The configured `server.builder` is expected to add
|
||
* the handlers it discovered by scanning, in addition to those registered through
|
||
* `serverHandlers`.
|
||
* @param routes Array of route handlers to be extended
|
||
* @param context Object the builder can extend
|
||
* @param context.requestTypes How the builder's types read a handler's validated request shapes
|
||
* @returns Promise
|
||
*/
|
||
"server:routes": (routes: ServerRouteHandler[], context: {
|
||
requestTypes?: ServerRequestTypes;
|
||
}) => HookResult;
|
||
/**
|
||
* Called when the dev middleware is being registered on the server builder's dev server.
|
||
* @param handler the Vite or Webpack event handler
|
||
* @returns Promise
|
||
*/
|
||
"server:devHandler": (handler: ServerEventHandler, options: {
|
||
cors: (path: string) => boolean;
|
||
}) => HookResult;
|
||
/**
|
||
* Called before the server builder writes `.nuxt/tsconfig.server.json`, allowing addition of custom references and declarations.
|
||
* @param options Objects containing `references`, `declarations`
|
||
* @param options.references Array of TypeScript references to add
|
||
* @param options.declarations Array of declaration strings to add
|
||
* @returns Promise
|
||
*/
|
||
"nitro:prepare:types": (options: {
|
||
references: TSReference[];
|
||
declarations: string[];
|
||
}) => HookResult;
|
||
/**
|
||
* Called before initializing the server builder, allowing customization of its configuration.
|
||
* @param nitroConfig The server builder config to be extended
|
||
* @returns Promise
|
||
*/
|
||
"nitro:config": (nitroConfig: NitroConfig) => HookResult;
|
||
/**
|
||
* Called after the server instance is initialized, which allows registering its hooks and interacting directly with it.
|
||
* @param nitro The created server instance
|
||
* @returns Promise
|
||
*/
|
||
"nitro:init": (nitro: NitroInstance) => HookResult;
|
||
/**
|
||
* Called before building the server instance.
|
||
* @param nitro The created server instance
|
||
* @returns Promise
|
||
*/
|
||
"nitro:build:before": (nitro: NitroInstance) => HookResult;
|
||
/**
|
||
* Called after copying public assets. Allows modifying public assets before the server is built.
|
||
* @param nitro The created server instance
|
||
* @returns Promise
|
||
*/
|
||
"nitro:build:public-assets": (nitro: NitroInstance) => HookResult;
|
||
/**
|
||
* Called before Nuxt bundle builder.
|
||
* @returns Promise
|
||
*/
|
||
"build:before": () => HookResult;
|
||
/**
|
||
* Called after Nuxt bundle builder is complete.
|
||
* @returns Promise
|
||
*/
|
||
"build:done": () => HookResult;
|
||
/**
|
||
* Called during the manifest build by Vite and Webpack. This allows customizing the manifest that Nitro will use to render `<script>` and `<link>` tags in the final HTML.
|
||
* @param manifest The manifest object to build
|
||
* @returns Promise
|
||
*/
|
||
"build:manifest": (manifest: NuxtManifest) => HookResult;
|
||
/**
|
||
* Called when `nuxt analyze` is finished
|
||
* @param meta the analyze meta object, mutations will be saved to `meta.json`
|
||
* @returns Promise
|
||
*/
|
||
"build:analyze:done": (meta: NuxtAnalyzeMeta) => HookResult;
|
||
/**
|
||
* Called before generating the app.
|
||
* @param options GenerateAppOptions object
|
||
* @returns Promise
|
||
*/
|
||
"builder:generateApp": (options?: GenerateAppOptions) => HookResult;
|
||
/**
|
||
* Called at build time in development when the watcher spots a change to a file or directory in the project.
|
||
* @param event "add" | "addDir" | "change" | "unlink" | "unlinkDir"
|
||
* @param path the path to the watched file
|
||
* @returns Promise
|
||
*/
|
||
"builder:watch": (event: WatchEvent, path: string) => HookResult;
|
||
/**
|
||
* Called after page routes are scanned from the file system.
|
||
* @param pages Array containing scanned pages
|
||
* @returns Promise
|
||
*/
|
||
"pages:extend": (pages: NuxtPage[]) => HookResult;
|
||
/**
|
||
* Called after page routes have been augmented with scanned metadata.
|
||
* @param pages Array containing resolved pages
|
||
* @returns Promise
|
||
*/
|
||
"pages:resolved": (pages: NuxtPage[]) => HookResult;
|
||
/**
|
||
* Called when resolving `app/router.options` files. It allows modifying the detected router options files
|
||
* and adding new ones.
|
||
*
|
||
* Later items in the array override earlier ones.
|
||
*
|
||
* Adding a router options file will switch on page-based routing, unless `optional` is set, in which case
|
||
* it will only apply when page-based routing is already enabled.
|
||
* @param context An object with `files` containing an array of router options files.
|
||
* @param context.files Array of router options files
|
||
* @returns Promise
|
||
*/
|
||
"pages:routerOptions": (context: {
|
||
files: Array<{
|
||
path: string;
|
||
optional?: boolean;
|
||
}>;
|
||
}) => HookResult;
|
||
/**
|
||
* Called at setup allowing modules to extend sources.
|
||
* @param presets Array containing presets objects
|
||
* @returns Promise
|
||
*/
|
||
"imports:sources": (presets: NuxtImportPresetSource[]) => HookResult;
|
||
/**
|
||
* Called at setup allowing modules to extend imports.
|
||
* @param imports Array containing the imports to extend
|
||
* @returns Promise
|
||
*/
|
||
"imports:extend": (imports: NuxtImport[]) => HookResult;
|
||
/**
|
||
* Called when the [unimport](https://github.com/unjs/unimport) context is created.
|
||
* @param context The Unimport context
|
||
* @returns Promise
|
||
*/
|
||
"imports:context": (context: Unimport) => HookResult;
|
||
/**
|
||
* Allows extending import directories.
|
||
* @param dirs Array containing directories as string
|
||
* @returns Promise
|
||
*/
|
||
"imports:dirs": (dirs: string[]) => HookResult;
|
||
/**
|
||
* Called within `app:resolve` allowing to extend the directories that are scanned for auto-importable components.
|
||
* @param dirs The `dirs` option to push new items
|
||
* @returns Promise
|
||
*/
|
||
"components:dirs": (dirs: ComponentsOptions["dirs"]) => HookResult;
|
||
/**
|
||
* Allows extending new components.
|
||
* @param components The `components` array to push new items
|
||
* @returns Promise
|
||
*/
|
||
"components:extend": (components: Component[]) => HookResult;
|
||
/**
|
||
* Allows extending the routes to be pre-rendered.
|
||
* @param ctx Nuxt context
|
||
* @param ctx.routes Set of routes to be pre-rendered
|
||
* @returns Promise
|
||
*/
|
||
"prerender:routes": (ctx: {
|
||
routes: Set<string>;
|
||
}) => HookResult;
|
||
/**
|
||
* Called when an error occurs at build time.
|
||
* @param error Error object
|
||
* @returns Promise
|
||
*/
|
||
"build:error": (error: Error) => HookResult;
|
||
/**
|
||
* Called before @nuxt/cli writes `.nuxt/tsconfig.json` and `.nuxt/nuxt.d.ts`, allowing addition of custom references and declarations in `nuxt.d.ts`, or directly modifying the options in `tsconfig.json`
|
||
* @param options Objects containing `references`, `declarations`, `tsConfig`
|
||
* @param options.references Array of TypeScript references to add
|
||
* @param options.declarations Array of declaration strings to add
|
||
* @param options.tsConfig The Vue TypeScript config object
|
||
* @param options.nodeTsConfig The Node TypeScript config object
|
||
* @param options.nodeReferences Array of Node TypeScript references
|
||
* @param options.sharedTsConfig The shared TypeScript config object
|
||
* @param options.sharedReferences Array of shared TypeScript references
|
||
* @param options.serverTsConfig The server TypeScript config object
|
||
* @param options.serverReferences Array of server TypeScript references
|
||
* @returns Promise
|
||
*/
|
||
"prepare:types": (options: {
|
||
references: TSReference[];
|
||
declarations: string[];
|
||
tsConfig: VueTSConfig;
|
||
nodeTsConfig: TSConfig;
|
||
nodeReferences: TSReference[];
|
||
sharedTsConfig: TSConfig;
|
||
sharedReferences: TSReference[];
|
||
serverTsConfig: TSConfig;
|
||
serverReferences: TSReference[];
|
||
}) => HookResult;
|
||
/**
|
||
* Called when the dev server is loading.
|
||
* @param listenerServer The HTTP/HTTPS server object
|
||
* @param listener The server's listener object
|
||
* @returns Promise
|
||
*/
|
||
"listen": (listenerServer: Server | Server$1, listener: any) => HookResult;
|
||
/**
|
||
* Allows extending default schemas.
|
||
* @param schemas Schemas to be extend
|
||
* @returns void
|
||
*/
|
||
"schema:extend": (schemas: SchemaDefinition[]) => void;
|
||
/**
|
||
* Allows extending resolved schema.
|
||
* @param schema Schema object
|
||
* @returns void
|
||
*/
|
||
"schema:resolved": (schema: Schema) => void;
|
||
/**
|
||
* Called before writing the given schema.
|
||
* @param schema Schema object
|
||
* @returns void
|
||
*/
|
||
"schema:beforeWrite": (schema: Schema) => void;
|
||
/**
|
||
* Called after the schema is written.
|
||
* @returns void
|
||
*/
|
||
"schema:written": () => void;
|
||
/**
|
||
* Allows to extend Vite default context.
|
||
* @param viteBuildContext The vite build context object
|
||
* @param viteBuildContext.nuxt The Nuxt instance
|
||
* @param viteBuildContext.config The Vite config object
|
||
* @returns Promise
|
||
*/
|
||
"vite:extend": (viteBuildContext: {
|
||
nuxt: Nuxt;
|
||
config: ViteConfig;
|
||
}) => HookResult;
|
||
/**
|
||
* Allows to extend Vite default config.
|
||
* @param viteInlineConfig The vite inline config object
|
||
* @param env Server or client
|
||
* @param env.isClient Whether the config is for the client build
|
||
* @param env.isServer Whether the config is for the server build
|
||
* @returns Promise
|
||
* @deprecated
|
||
*/
|
||
"vite:extendConfig": (viteInlineConfig: Readonly<ViteConfig>, env: {
|
||
isClient: boolean;
|
||
isServer: boolean;
|
||
}) => HookResult;
|
||
/**
|
||
* Allows to read the resolved Vite config.
|
||
* @param viteInlineConfig The vite inline config object
|
||
* @param env Server or client
|
||
* @param env.isClient Whether the config is for the client build
|
||
* @param env.isServer Whether the config is for the server build
|
||
* @returns Promise
|
||
* @deprecated
|
||
*/
|
||
"vite:configResolved": (viteInlineConfig: Readonly<ViteConfig>, env: {
|
||
isClient: boolean;
|
||
isServer: boolean;
|
||
}) => HookResult;
|
||
/**
|
||
* Called when the Vite server is created.
|
||
* @param viteServer Vite development server
|
||
* @param env Server or client
|
||
* @param env.isClient Whether the server is for the client build
|
||
* @param env.isServer Whether the server is for the server build
|
||
* @returns Promise
|
||
*/
|
||
"vite:serverCreated": (viteServer: ViteDevServer, env: {
|
||
isClient: boolean;
|
||
isServer: boolean;
|
||
}) => HookResult;
|
||
/**
|
||
* Called after Vite server is compiled.
|
||
* @returns Promise
|
||
*/
|
||
"vite:compiled": () => HookResult;
|
||
/**
|
||
* Called before configuring the webpack compiler.
|
||
* @param webpackConfigs Configs objects to be pushed to the compiler
|
||
* @returns Promise
|
||
*/
|
||
"webpack:config": (webpackConfigs: Configuration[]) => HookResult;
|
||
/**
|
||
* Allows to read the resolved webpack config
|
||
* @param webpackConfigs Configs objects to be pushed to the compiler
|
||
* @returns Promise
|
||
*/
|
||
"webpack:configResolved": (webpackConfigs: Readonly<Configuration>[]) => HookResult;
|
||
/**
|
||
* Called right before compilation.
|
||
* @param options The options to be added
|
||
* @param options.name The name of the compiler
|
||
* @param options.compiler The webpack compiler instance
|
||
* @returns Promise
|
||
*/
|
||
"webpack:compile": (options: {
|
||
name: string;
|
||
compiler: Compiler;
|
||
}) => HookResult;
|
||
/**
|
||
* Called after resources are loaded.
|
||
* @param options The compiler options
|
||
* @param options.name The name of the compiler
|
||
* @param options.compiler The webpack compiler instance
|
||
* @param options.stats The webpack compilation stats
|
||
* @returns Promise
|
||
*/
|
||
"webpack:compiled": (options: {
|
||
name: string;
|
||
compiler: Compiler;
|
||
stats: Stats;
|
||
}) => HookResult;
|
||
/**
|
||
* Called on `change` on WebpackBar.
|
||
* @param shortPath the short path
|
||
* @returns void
|
||
*/
|
||
"webpack:change": (shortPath: string) => void;
|
||
/**
|
||
* Called on `done` if has errors on WebpackBar.
|
||
* @returns void
|
||
*/
|
||
"webpack:error": () => void;
|
||
/**
|
||
* Called on `allDone` on WebpackBar.
|
||
* @returns void
|
||
*/
|
||
"webpack:done": () => void;
|
||
/**
|
||
* Called on `progress` on WebpackBar.
|
||
* @param statesArray The array containing the states on progress
|
||
* @returns void
|
||
*/
|
||
"webpack:progress": (statesArray: any[]) => void;
|
||
/**
|
||
* Called before configuring the webpack compiler.
|
||
* @param webpackConfigs Configs objects to be pushed to the compiler
|
||
* @returns Promise
|
||
*/
|
||
"rspack:config": (webpackConfigs: Configuration[]) => HookResult;
|
||
/**
|
||
* Allows to read the resolved webpack config
|
||
* @param webpackConfigs Configs objects to be pushed to the compiler
|
||
* @returns Promise
|
||
*/
|
||
"rspack:configResolved": (webpackConfigs: Readonly<Configuration>[]) => HookResult;
|
||
/**
|
||
* Called right before compilation.
|
||
* @param options The options to be added
|
||
* @param options.name The name of the compiler
|
||
* @param options.compiler The rspack compiler instance
|
||
* @returns Promise
|
||
*/
|
||
"rspack:compile": (options: {
|
||
name: string;
|
||
compiler: Compiler;
|
||
}) => HookResult;
|
||
/**
|
||
* Called after resources are loaded.
|
||
* @param options The compiler options
|
||
* @param options.name The name of the compiler
|
||
* @param options.compiler The rspack compiler instance
|
||
* @param options.stats The rspack compilation stats
|
||
* @returns Promise
|
||
*/
|
||
"rspack:compiled": (options: {
|
||
name: string;
|
||
compiler: Compiler;
|
||
stats: Stats;
|
||
}) => HookResult;
|
||
/**
|
||
* Called on `change` on WebpackBar.
|
||
* @param shortPath the short path
|
||
* @returns void
|
||
*/
|
||
"rspack:change": (shortPath: string) => void;
|
||
/**
|
||
* Called on `done` if has errors on WebpackBar.
|
||
* @returns void
|
||
*/
|
||
"rspack:error": () => void;
|
||
/**
|
||
* Called on `allDone` on WebpackBar.
|
||
* @returns void
|
||
*/
|
||
"rspack:done": () => void;
|
||
/**
|
||
* Called on `progress` on WebpackBar.
|
||
* @param statesArray The array containing the states on progress
|
||
* @returns void
|
||
*/
|
||
"rspack:progress": (statesArray: any[]) => void;
|
||
}
|
||
type NuxtHookName = keyof NuxtHooks;
|
||
type MetaObjectRaw = SerializableHead;
|
||
type MetaObject = MetaObjectRaw;
|
||
type AppHeadMetaObject = MetaObjectRaw & {
|
||
/**
|
||
* The character encoding in which the document is encoded => `<meta charset="<value>" />`
|
||
*/
|
||
charset?: string;
|
||
/**
|
||
* Configuration of the viewport (the area of the window in which web content can be seen),
|
||
* mapped to => `<meta name="viewport" content="<value>" />`
|
||
*/
|
||
viewport?: string;
|
||
};
|
||
type SerializableHtmlAttributes = GlobalAttributes & AriaAttributes & DataKeys;
|
||
interface ConfigSchema {
|
||
/**
|
||
* Configure Nuxt component auto-registration.
|
||
*
|
||
* Any components in the directories configured here can be used throughout your pages, layouts (and other components) without needing to explicitly import them.
|
||
*
|
||
* @see [`components/` directory documentation](https://nuxt.com/docs/4.x/directory-structure/app/components)
|
||
*/
|
||
components: boolean | ComponentsOptions | ComponentsOptions["dirs"];
|
||
/**
|
||
* Configure how Nuxt auto-imports composables into your application.
|
||
*
|
||
* @see [Nuxt documentation](https://nuxt.com/docs/4.x/directory-structure/app/composables)
|
||
*/
|
||
imports: ImportsOptions;
|
||
/**
|
||
* Configure the Nuxt compiler.
|
||
*/
|
||
compiler: NuxtCompilerOptions;
|
||
/**
|
||
* Whether to use the vue-router integration in Nuxt 3. If you do not provide a value it will be enabled if you have a `pages/` directory in your source folder.
|
||
*
|
||
* Additionally, you can provide a glob pattern or an array of patterns to scan only certain files for pages.
|
||
*
|
||
* @example
|
||
* ```js
|
||
* pages: {
|
||
* pattern: ['**\/*\/*.vue', '!**\/*.spec.*'],
|
||
* }
|
||
* ```
|
||
*/
|
||
pages: boolean | {
|
||
enabled?: boolean;
|
||
pattern?: string | string[];
|
||
};
|
||
/**
|
||
* Manually disable nuxt telemetry.
|
||
*
|
||
* @see [Nuxt Telemetry](https://github.com/nuxt/telemetry) for more information.
|
||
*/
|
||
telemetry: boolean | Record<string, any>;
|
||
/**
|
||
* Enable Nuxt DevTools for development.
|
||
*
|
||
* Breaking changes for devtools might not reflect on the version of Nuxt.
|
||
*
|
||
* @see [Nuxt DevTools](https://nuxt.com/modules/devtools) for more information.
|
||
*/
|
||
devtools: boolean | {
|
||
enabled: boolean;
|
||
[key: string]: any;
|
||
};
|
||
/**
|
||
* Vue.js config
|
||
*/
|
||
vue: {
|
||
transformAssetUrls: AssetURLTagConfig;
|
||
/**
|
||
* Options for the Vue compiler that will be passed at build time.
|
||
*
|
||
* @see [Vue documentation](https://vuejs.org/api/application#app-config-compileroptions)
|
||
*/
|
||
compilerOptions: CompilerOptions;
|
||
/**
|
||
* Include Vue compiler in runtime bundle.
|
||
*
|
||
* Enabling this allows components to compile templates at runtime (for example,
|
||
* string `template` options or templates supplied via data).
|
||
*
|
||
* Runtime-compiled templates can execute arbitrary JavaScript. Never pass
|
||
* user-provided or otherwise untrusted content to a runtime-compiled template;
|
||
* treat any string that reaches the compiler as executable code.
|
||
*
|
||
* @see [Vue security guide](https://vuejs.org/guide/best-practices/security.html)
|
||
*/
|
||
runtimeCompiler: boolean;
|
||
/**
|
||
* Include support for the Vue Options API in the client bundle.
|
||
*
|
||
* Disabling this compiles out Vue's Options API runtime (via the `__VUE_OPTIONS_API__` feature
|
||
* flag), shrinking the client bundle for apps that only use the Composition API / `<script setup>`.
|
||
*
|
||
* Defaults to `false` when `future.compatibilityVersion` is `5` or higher, otherwise `true`.
|
||
*/
|
||
optionsApi: boolean;
|
||
/**
|
||
* Enable reactive destructure for `defineProps`
|
||
*/
|
||
propsDestructure: boolean;
|
||
/**
|
||
* Enable experimental support for Vue Vapor Mode (requires Vue 3.6+).
|
||
*/
|
||
vapor: boolean;
|
||
/**
|
||
* It is possible to pass configure the Vue app globally. Only serializable options may be set in your `nuxt.config`. All other options should be set at runtime in a Nuxt plugin.
|
||
*
|
||
* @see [Vue app config documentation](https://vuejs.org/api/application#app-config)
|
||
*/
|
||
config: Serializable<AppConfig>;
|
||
};
|
||
/**
|
||
* Nuxt App configuration.
|
||
*/
|
||
app: {
|
||
/**
|
||
* The base path of your Nuxt application.
|
||
*
|
||
* For example:
|
||
*
|
||
*
|
||
* @example
|
||
* ```ts
|
||
* export default defineNuxtConfig({
|
||
* app: {
|
||
* baseURL: '/prefix/'
|
||
* }
|
||
* })
|
||
* ```
|
||
*
|
||
* This can also be set at runtime by setting the NUXT_APP_BASE_URL environment variable.
|
||
*
|
||
* @example
|
||
* ```bash
|
||
* NUXT_APP_BASE_URL=/prefix/ NODE_ENV=production node .output/server/index.mjs
|
||
* ```
|
||
*/
|
||
baseURL: string;
|
||
/**
|
||
* The folder name for the built site assets, relative to `baseURL` (or `cdnURL` if set). This is set at build time and should not be customized at runtime.
|
||
*/
|
||
buildAssetsDir: string;
|
||
/**
|
||
* An absolute URL to serve the public folder from (production-only).
|
||
*
|
||
* For example:
|
||
*
|
||
* @example
|
||
* ```ts
|
||
* export default defineNuxtConfig({
|
||
* app: {
|
||
* cdnURL: 'https://mycdn.org/'
|
||
* }
|
||
* })
|
||
* ```
|
||
*
|
||
* This can be set to a different value at runtime by setting the `NUXT_APP_CDN_URL` environment variable.
|
||
*
|
||
* @example
|
||
* ```bash
|
||
* NUXT_APP_CDN_URL=https://mycdn.org/ NODE_ENV=production node .output/server/index.mjs
|
||
* ```
|
||
*/
|
||
cdnURL: string;
|
||
/**
|
||
* Set default configuration for `<head>` on every page.
|
||
*
|
||
* @example
|
||
* ```js
|
||
* app: {
|
||
* head: {
|
||
* meta: [
|
||
* // <meta name="viewport" content="width=device-width, initial-scale=1">
|
||
* { name: 'viewport', content: 'width=device-width, initial-scale=1' }
|
||
* ],
|
||
* script: [
|
||
* // <script src="https://myawesome-lib.js"><\/script>
|
||
* { src: 'https://awesome-lib.js' }
|
||
* ],
|
||
* link: [
|
||
* // <link rel="stylesheet" href="https://myawesome-lib.css">
|
||
* { rel: 'stylesheet', href: 'https://awesome-lib.css' }
|
||
* ],
|
||
* // please note that this is an area that is likely to change
|
||
* style: [
|
||
* // <style>:root { color: red }</style>
|
||
* { textContent: ':root { color: red }' }
|
||
* ],
|
||
* noscript: [
|
||
* // <noscript>JavaScript is required</noscript>
|
||
* { textContent: 'JavaScript is required' }
|
||
* ]
|
||
* }
|
||
* }
|
||
* ```
|
||
*/
|
||
head: NuxtAppConfig["head"];
|
||
/**
|
||
* Default values for layout transitions.
|
||
*
|
||
* This can be overridden with `definePageMeta` on an individual page. Only JSON-serializable values are allowed.
|
||
*
|
||
* @see [Vue Transition docs](https://vuejs.org/api/built-in-components#transition)
|
||
*/
|
||
layoutTransition: NuxtAppConfig["layoutTransition"];
|
||
/**
|
||
* Default values for page transitions.
|
||
*
|
||
* This can be overridden with `definePageMeta` on an individual page. Only JSON-serializable values are allowed.
|
||
*
|
||
* @see [Vue Transition docs](https://vuejs.org/api/built-in-components#transition)
|
||
*/
|
||
pageTransition: NuxtAppConfig["pageTransition"];
|
||
/**
|
||
* Default values for view transitions.
|
||
*
|
||
* This only has an effect when **experimental** support for View Transitions is [enabled in your nuxt.config file](https://nuxt.com/docs/4.x/getting-started/transitions#view-transitions-api-experimental).
|
||
* This can be overridden with `definePageMeta` on an individual page.
|
||
*
|
||
* @see [Nuxt View Transition API docs](https://nuxt.com/docs/4.x/getting-started/transitions#view-transitions-api-experimental)
|
||
*/
|
||
viewTransition: NuxtAppConfig["viewTransition"];
|
||
/**
|
||
* Default values for KeepAlive configuration between pages.
|
||
*
|
||
* This can be overridden with `definePageMeta` on an individual page. Only JSON-serializable values are allowed.
|
||
*
|
||
* @see [Vue KeepAlive](https://vuejs.org/api/built-in-components#keepalive)
|
||
*/
|
||
keepalive: NuxtAppConfig["keepalive"];
|
||
/**
|
||
* Customize Nuxt root element id.
|
||
*
|
||
* @deprecated Prefer `rootAttrs.id` instead
|
||
*/
|
||
rootId: string | false;
|
||
/**
|
||
* Customize Nuxt root element tag.
|
||
*/
|
||
rootTag: string;
|
||
/**
|
||
* Customize Nuxt root element id.
|
||
*/
|
||
rootAttrs: SerializableHtmlAttributes;
|
||
/**
|
||
* Customize Nuxt Teleport element tag.
|
||
*/
|
||
teleportTag: string;
|
||
/**
|
||
* Customize Nuxt Teleport element id.
|
||
*
|
||
* @deprecated Prefer `teleportAttrs.id` instead
|
||
*/
|
||
teleportId: string | false;
|
||
/**
|
||
* Customize Nuxt Teleport element attributes.
|
||
*/
|
||
teleportAttrs: SerializableHtmlAttributes;
|
||
/**
|
||
* Customize Nuxt SpaLoader element tag.
|
||
*/
|
||
spaLoaderTag: string;
|
||
/**
|
||
* Customize Nuxt SPA loading template element attributes.
|
||
*/
|
||
spaLoaderAttrs: SerializableHtmlAttributes;
|
||
};
|
||
/**
|
||
* Boolean or a path to an HTML file with the contents of which will be inserted into any HTML page rendered with `ssr: false`.
|
||
*
|
||
* - If it is unset, it will use the `spa-loading-template.html` file in the `app/` directory of one of your layers, if it exists.
|
||
* - If it is false, no SPA loading indicator will be loaded.
|
||
* - If true, Nuxt will look for the `spa-loading-template.html` file in the `app/` directory of one of your layers, or a default Nuxt image will be used.
|
||
* - If it is a path, it is resolved relative to `srcDir`.
|
||
*
|
||
* Some good sources for spinners are [SpinKit](https://github.com/tobiasahlin/SpinKit) or [SVG Spinners](https://icones.js.org/collection/svg-spinners).
|
||
*
|
||
* @example app/spa-loading-template.html
|
||
* ```html
|
||
* <!-- https://github.com/barelyhuman/snips/blob/dev/pages/css-loader.md -->
|
||
* <div class="loader"></div>
|
||
* <style>
|
||
* .loader {
|
||
* display: block;
|
||
* position: fixed;
|
||
* z-index: 1031;
|
||
* top: 50%;
|
||
* left: 50%;
|
||
* transform: translate(-50%, -50%);
|
||
* width: 18px;
|
||
* height: 18px;
|
||
* box-sizing: border-box;
|
||
* border: solid 2px transparent;
|
||
* border-top-color: #000;
|
||
* border-left-color: #000;
|
||
* border-bottom-color: #efefef;
|
||
* border-right-color: #efefef;
|
||
* border-radius: 50%;
|
||
* -webkit-animation: loader 400ms linear infinite;
|
||
* animation: loader 400ms linear infinite;
|
||
* }
|
||
*
|
||
* @-webkit-keyframes loader {
|
||
* 0% {
|
||
* -webkit-transform: translate(-50%, -50%) rotate(0deg);
|
||
* }
|
||
* 100% {
|
||
* -webkit-transform: translate(-50%, -50%) rotate(360deg);
|
||
* }
|
||
* }
|
||
* @keyframes loader {
|
||
* 0% {
|
||
* transform: translate(-50%, -50%) rotate(0deg);
|
||
* }
|
||
* 100% {
|
||
* transform: translate(-50%, -50%) rotate(360deg);
|
||
* }
|
||
* }
|
||
* </style>
|
||
* ```
|
||
*/
|
||
spaLoadingTemplate: string | boolean | undefined | null;
|
||
/**
|
||
* An array of nuxt app plugins.
|
||
*
|
||
* Each plugin can be a string (which can be an absolute or relative path to a file). If it ends with `.client` or `.server` then it will be automatically loaded only in the appropriate context.
|
||
* It can also be an object with `src` and `mode` keys.
|
||
*
|
||
* @note Plugins are also auto-registered from the `~/plugins` directory
|
||
* and these plugins do not need to be listed in `nuxt.config` unless you
|
||
* need to customize their order. All plugins are deduplicated by their src path.
|
||
*
|
||
* @see [`plugins/` directory documentation](https://nuxt.com/docs/4.x/directory-structure/app/plugins)
|
||
*
|
||
* @example
|
||
* ```js
|
||
* plugins: [
|
||
* '~/plugins/foo.client.js', // only in client side
|
||
* '~/plugins/bar.server.js', // only in server side
|
||
* '~/plugins/baz.js', // both client & server
|
||
* { src: '~/plugins/both-sides.js' },
|
||
* { src: '~/plugins/client-only.js', mode: 'client' }, // only on client side
|
||
* { src: '~/plugins/server-only.js', mode: 'server' } // only on server side
|
||
* ]
|
||
* ```
|
||
*/
|
||
plugins: (NuxtPlugin | string)[];
|
||
/**
|
||
* You can define the CSS files/modules/libraries you want to set globally (included in every page).
|
||
*
|
||
* Nuxt will automatically guess the file type by its extension and use the appropriate pre-processor. You will still need to install the required loader if you need to use them.
|
||
*
|
||
* @example
|
||
* ```js
|
||
* css: [
|
||
* // Load a Node.js module directly (here it's a Sass file).
|
||
* 'bulma',
|
||
* // CSS file in the project
|
||
* '~/assets/css/main.css',
|
||
* // SCSS file in the project
|
||
* '~/assets/css/main.scss'
|
||
* ]
|
||
* ```
|
||
*/
|
||
css: string[];
|
||
/**
|
||
* An object that allows us to configure the `unhead` nuxt module.
|
||
*/
|
||
unhead: {
|
||
/**
|
||
* Disables Capo.js head tag sorting.
|
||
*
|
||
* On compat v4, the unhead legacy plugin set (`DeprecationsPlugin`, `PromisesPlugin`,
|
||
* `TemplateParamsPlugin`, `AliasSortingPlugin`) is always loaded so existing head patterns
|
||
* (`hid`, `vmid`, `children`, `body: true`, promise values, `%s` template params)
|
||
* keep working.
|
||
*
|
||
* Forced to `false` when `future.compatibilityVersion` >= 5.
|
||
*
|
||
* @deprecated Will be removed. Migrate off the deprecated head patterns and resolve promise
|
||
* values before passing to `useHead`.
|
||
* @default false
|
||
*/
|
||
legacy: boolean;
|
||
/**
|
||
* An object that will be passed to `renderSSRHead` to customize the output.
|
||
*/
|
||
renderSSRHeadOptions: RenderSSRHeadOptions;
|
||
/**
|
||
* Options for the `@unhead/vue/vite` build plugin. Provides tree-shaking, `useSeoMeta` transform,
|
||
* minification, and validation.
|
||
*
|
||
* Set to `false` to disable the plugin entirely.
|
||
*
|
||
* Only applies when `future.compatibilityVersion` >= 5.
|
||
*
|
||
* @default {}
|
||
*/
|
||
vite: false | Omit<UnheadVueViteOptions, "streaming" | "_framework">;
|
||
};
|
||
/**
|
||
* The builder to use for bundling the Vue part of your application.
|
||
*
|
||
*/
|
||
builder: "vite" | "webpack" | "rspack" | {
|
||
bundle: (nuxt: Nuxt) => Promise<void>;
|
||
};
|
||
/**
|
||
* Configures whether and how sourcemaps are generated for server and/or client bundles.
|
||
*
|
||
* If set to a single boolean, that value applies to both server and client. Additionally, the `'hidden'` option is also available for both server and client.
|
||
* Available options for both client and server: - `true`: Generates sourcemaps and includes source references in the final bundle. - `false`: Does not generate any sourcemaps. - `'hidden'`: Generates sourcemaps but does not include references in the final bundle.
|
||
*/
|
||
sourcemap: boolean | {
|
||
server?: boolean | "hidden";
|
||
client?: boolean | "hidden";
|
||
};
|
||
/**
|
||
* Log level when building logs.
|
||
*
|
||
* Defaults to 'silent' when running in CI or when a TTY is not available. This option is then used as 'silent' in Vite and 'none' in Webpack
|
||
*
|
||
*/
|
||
logLevel: "silent" | "info" | "verbose";
|
||
/**
|
||
* Shared build configuration.
|
||
*/
|
||
build: {
|
||
/**
|
||
* If you want to transpile specific dependencies with Babel, you can add them here. Each item in transpile can be a package name, a function, a string or regex object matching the dependency's file name.
|
||
*
|
||
* You can also use a function to conditionally transpile. The function will receive an object ({ isDev, isServer, isClient, isModern, isLegacy }).
|
||
*
|
||
* @example
|
||
* ```js
|
||
* transpile: [({ isLegacy }) => isLegacy && 'ky']
|
||
* ```
|
||
*/
|
||
transpile: Array<string | RegExp | ((ctx: {
|
||
isClient?: boolean;
|
||
isServer?: boolean;
|
||
isDev: boolean;
|
||
}) => string | RegExp | false)>;
|
||
/**
|
||
* It is recommended to use `addTemplate` from `@nuxt/kit` instead of this option.
|
||
*
|
||
* @example
|
||
* ```js
|
||
* templates: [
|
||
* {
|
||
* src: '~/modules/support/plugin.js', // `src` can be absolute or relative
|
||
* dst: 'support.js', // `dst` is relative to project `.nuxt` dir
|
||
* }
|
||
* ]
|
||
* ```
|
||
*/
|
||
templates: NuxtTemplate<any>[];
|
||
/**
|
||
* Nuxt allows visualizing your bundles and how to optimize them.
|
||
*
|
||
* Set to `true` to enable bundle analysis, or pass an object with options: [for webpack](https://github.com/webpack/webpack-bundle-analyzer#options-for-plugin) or [for vite](https://github.com/btd/rollup-plugin-visualizer#options).
|
||
*
|
||
* @example
|
||
* ```js
|
||
* analyze: {
|
||
* analyzerMode: 'static'
|
||
* }
|
||
* ```
|
||
*/
|
||
analyze: boolean | {
|
||
enabled?: boolean;
|
||
} & ((0 extends 1 & BundleAnalyzerPlugin.Options ? Record<string, unknown> : BundleAnalyzerPlugin.Options) | PluginVisualizerOptions);
|
||
};
|
||
/**
|
||
* Build time optimization configuration.
|
||
*/
|
||
optimization: {
|
||
/**
|
||
* Functions to inject a key for.
|
||
*
|
||
* As long as the number of arguments passed to the function is lower than `argumentLength`, an additional magic string will be injected that can be used to deduplicate requests between server and client. You will need to take steps to handle this additional key.
|
||
* The key will be unique based on the location of the function being invoked within the file.
|
||
*
|
||
*/
|
||
keyedComposables: KeyedFunction[];
|
||
/**
|
||
* Factories for functions that should be registered for automatic key injection.
|
||
*
|
||
* @see keyedComposables
|
||
*/
|
||
keyedComposableFactories: KeyedFunctionFactory[];
|
||
/**
|
||
* Tree shake code from specific builds.
|
||
*/
|
||
treeShake: {
|
||
/**
|
||
* Tree shake composables from the server or client builds.
|
||
*
|
||
*
|
||
* @example
|
||
* ```js
|
||
* treeShake: { client: { myPackage: ['useServerOnlyComposable'] } }
|
||
* ```
|
||
*/
|
||
composables: {
|
||
server: Record<string, string[]>;
|
||
client: Record<string, string[]>;
|
||
};
|
||
};
|
||
/**
|
||
* Options passed directly to the transformer from `unctx` that preserves async context after `await`.
|
||
*/
|
||
asyncTransforms: TransformerOptions;
|
||
};
|
||
/**
|
||
* Extend project from multiple local or remote sources.
|
||
*
|
||
* Value should be either a string or array of strings pointing to source directories or config path relative to current config.
|
||
* You can use `github:`, `gh:` `gitlab:` or `bitbucket:`
|
||
*
|
||
* @see [`giget` documentation](https://github.com/unjs/giget)
|
||
*/
|
||
extends: string | [string, NuxtLayerSourceOptions?] | (string | [string, NuxtLayerSourceOptions?])[];
|
||
/**
|
||
* Specify a compatibility date for your app.
|
||
*
|
||
* This is used to control the behavior of presets in Nitro, Nuxt Image and other modules that may change behavior without a major version bump.
|
||
* We plan to improve the tooling around this feature in the future.
|
||
*/
|
||
compatibilityDate: CompatibilityDateSpec;
|
||
/**
|
||
* Extend project from a local or remote source.
|
||
*
|
||
* Value should be a string pointing to source directory or config path relative to current config.
|
||
* You can use `github:`, `gitlab:`, `bitbucket:` or `https://` to extend from a remote git repository.
|
||
*/
|
||
theme: string;
|
||
/**
|
||
* Define the root directory of your application.
|
||
*
|
||
* This property can be overwritten (for example, running `nuxt ./my-app/` will set the `rootDir` to the absolute path of `./my-app/` from the current/working directory.
|
||
* It is normally not needed to configure this option.
|
||
*
|
||
*/
|
||
rootDir: string;
|
||
/**
|
||
* Define the workspace directory of your application.
|
||
*
|
||
* Often this is used when in a monorepo setup. Nuxt will attempt to detect your workspace directory automatically, but you can override it here.
|
||
* It is normally not needed to configure this option.
|
||
*
|
||
*/
|
||
workspaceDir: string;
|
||
/**
|
||
* Define the source directory of your Nuxt application.
|
||
*
|
||
* If a relative path is specified, it will be relative to the `rootDir`.
|
||
*
|
||
*
|
||
* @example
|
||
* ```js
|
||
* export default {
|
||
* srcDir: 'app/'
|
||
* }
|
||
* ```
|
||
* This expects the following folder structure:
|
||
* ```bash
|
||
* -| app/
|
||
* ---| assets/
|
||
* ---| components/
|
||
* ---| layouts/
|
||
* ---| middleware/
|
||
* ---| pages/
|
||
* ---| plugins/
|
||
* ---| app.config.ts
|
||
* ---| app.vue
|
||
* ---| error.vue
|
||
* -| server/
|
||
* -| public/
|
||
* -| modules/
|
||
* -| nuxt.config.js
|
||
* -| package.json
|
||
* ```
|
||
*/
|
||
srcDir: string;
|
||
/**
|
||
* Define the server directory of your Nuxt application, where Nitro routes, middleware and plugins are kept.
|
||
*
|
||
* If a relative path is specified, it will be relative to your `rootDir`.
|
||
*
|
||
*/
|
||
serverDir: string;
|
||
/**
|
||
* Define the directory where your built Nuxt files will be placed.
|
||
*
|
||
* Many tools assume that `.nuxt` is a hidden directory (because it starts with a `.`). If that is a problem, you can use this option to prevent that.
|
||
*
|
||
*
|
||
* @example
|
||
* ```js
|
||
* export default {
|
||
* buildDir: 'nuxt-build'
|
||
* }
|
||
* ```
|
||
*/
|
||
buildDir: string;
|
||
/**
|
||
* Define the directory where generated types and `tsconfig.json` files will be placed.
|
||
*
|
||
* This defaults to your `buildDir`, and is separate from it so that the configurations
|
||
* referenced by your project `tsconfig.json` stay in place even when Nuxt builds
|
||
* elsewhere (as it does when building a project that has already been run in
|
||
* development).
|
||
*
|
||
* If a relative path is specified, it will be relative to your `rootDir`.
|
||
*/
|
||
typesDir: string;
|
||
/**
|
||
* For multi-app projects, the unique id of the Nuxt application.
|
||
*
|
||
* Defaults to `nuxt-app`.
|
||
*
|
||
*/
|
||
appId: string;
|
||
/**
|
||
* A unique identifier matching the build. This may contain the hash of the current state of the project.
|
||
*
|
||
*/
|
||
buildId: string;
|
||
/**
|
||
* Used to set the modules directories for path resolving (for example, webpack's `resolveLoading`, `nodeExternals` and `postcss`).
|
||
*
|
||
* The configuration path is relative to `options.rootDir` (default is current working directory).
|
||
* Setting this field may be necessary if your project is organized as a yarn workspace-styled mono-repository.
|
||
*
|
||
*
|
||
* @example
|
||
* ```js
|
||
* export default {
|
||
* modulesDir: ['../../node_modules']
|
||
* }
|
||
* ```
|
||
*/
|
||
modulesDir: Array<string>;
|
||
/**
|
||
* The directory where Nuxt will store the generated files when running `nuxt analyze`.
|
||
*
|
||
* If a relative path is specified, it will be relative to your `rootDir`.
|
||
*
|
||
*/
|
||
analyzeDir: string;
|
||
/**
|
||
* Whether Nuxt is running in development mode.
|
||
*
|
||
* Normally, you should not need to set this.
|
||
*
|
||
*/
|
||
dev: boolean;
|
||
/**
|
||
* Whether your app is being unit tested.
|
||
*
|
||
*/
|
||
test: boolean;
|
||
/**
|
||
* The active Nuxt environment name, used to select configuration
|
||
* overrides (e.g. `$env.staging`). Defaults to the explicit `envName` passed to
|
||
* `loadNuxtConfig` (e.g. via `nuxt --envName`), falling back to `'development'`
|
||
* in dev mode and `'production'` otherwise.
|
||
*
|
||
* Exposed to runtime app code as `import.meta.envName`.
|
||
*
|
||
*/
|
||
envName: string;
|
||
/**
|
||
* Set to `true` to enable debug mode.
|
||
*
|
||
* At the moment, it prints out hook names and timings on the server, and logs hook arguments as well in the browser.
|
||
* You can also set this to an object to enable specific debug options.
|
||
*
|
||
*/
|
||
debug: boolean | (NuxtDebugOptions) | undefined;
|
||
/**
|
||
* Whether to enable rendering of HTML - either dynamically (in server mode) or at generate time. If set to `false` generated pages will have no content.
|
||
*
|
||
*/
|
||
ssr: boolean;
|
||
/**
|
||
* Modules are Nuxt extensions which can extend its core functionality and add endless integrations.
|
||
*
|
||
* Each module is either a string (which can refer to a package, or be a path to a file), a tuple with the module as first string and the options as a second object, or an inline module function.
|
||
* Nuxt tries to resolve each item in the modules array using node require path (in `node_modules`) and then will be resolved from project `srcDir` if `~` alias is used.
|
||
*
|
||
* @note Modules are executed sequentially so the order is important. First, the modules defined in `nuxt.config.ts` are loaded. Then, modules found in the `modules/`
|
||
* directory are executed, and they load in alphabetical order.
|
||
*
|
||
* @example
|
||
* ```js
|
||
* modules: [
|
||
* // Using package name
|
||
* '@nuxtjs/axios',
|
||
* // Relative to your project srcDir
|
||
* '~/modules/awesome.js',
|
||
* // Providing options
|
||
* ['@nuxtjs/google-analytics', { ua: 'X1234567' }],
|
||
* // Inline definition
|
||
* function () {}
|
||
* ]
|
||
* ```
|
||
*/
|
||
modules: (NuxtModule<any> | string | [NuxtModule | string, Record<string, any>] | undefined | null | false)[];
|
||
/**
|
||
* Customize default directory structure used by Nuxt.
|
||
*
|
||
* It is better to stick with defaults unless needed.
|
||
*/
|
||
dir: {
|
||
app: string;
|
||
/**
|
||
* The assets directory (aliased as `~assets` in your build).
|
||
*/
|
||
assets: string;
|
||
/**
|
||
* The layouts directory, each file of which will be auto-registered as a Nuxt layout.
|
||
*/
|
||
layouts: string;
|
||
/**
|
||
* The middleware directory, each file of which will be auto-registered as a Nuxt middleware.
|
||
*/
|
||
middleware: string;
|
||
/**
|
||
* The modules directory, each file in which will be auto-registered as a Nuxt module.
|
||
*/
|
||
modules: string;
|
||
/**
|
||
* The directory which will be processed to auto-generate your application page routes.
|
||
*/
|
||
pages: string;
|
||
/**
|
||
* The plugins directory, each file of which will be auto-registered as a Nuxt plugin.
|
||
*/
|
||
plugins: string;
|
||
/**
|
||
* The shared directory. This directory is shared between the app and the server.
|
||
*/
|
||
shared: string;
|
||
/**
|
||
* The directory containing your static files, which will be directly accessible via the Nuxt server and copied across into your `dist` folder when your app is generated.
|
||
*/
|
||
public: string;
|
||
};
|
||
/**
|
||
* The extensions that should be resolved by the Nuxt resolver.
|
||
*
|
||
*/
|
||
extensions: Array<string>;
|
||
/**
|
||
* You can improve your DX by defining additional aliases to access custom directories within your JavaScript and CSS.
|
||
*
|
||
* @note Within a webpack context (image sources, CSS - but not JavaScript) you _must_ access
|
||
* your alias by prefixing it with `~`.
|
||
*
|
||
* @note These aliases will be automatically added to the generated `.nuxt/tsconfig.json` so you can get full
|
||
* type support and path auto-complete. In case you need to extend options provided by `./.nuxt/tsconfig.json`
|
||
* further, make sure to add them here or within the `typescript.tsConfig` property in `nuxt.config`.
|
||
*
|
||
* @example
|
||
* ```js
|
||
* export default {
|
||
* alias: {
|
||
* 'images': fileURLToPath(new URL('./assets/images', import.meta.url)),
|
||
* 'style': fileURLToPath(new URL('./assets/style', import.meta.url)),
|
||
* 'data': fileURLToPath(new URL('./assets/other/data', import.meta.url))
|
||
* }
|
||
* }
|
||
* ```
|
||
*
|
||
* ```html
|
||
* <template>
|
||
* <img src="~images/main-bg.jpg">
|
||
* </template>
|
||
*
|
||
* <script>
|
||
* import data from 'data/test.json'
|
||
* <\/script>
|
||
*
|
||
* <style>
|
||
* // Uncomment the below
|
||
* //@import '~style/variables.scss';
|
||
* //@import '~style/utils.scss';
|
||
* //@import '~style/base.scss';
|
||
* body {
|
||
* background-image: url('~images/main-bg.jpg');
|
||
* }
|
||
* </style>
|
||
* ```
|
||
*/
|
||
alias: Record<string, string>;
|
||
/**
|
||
* Pass options directly to `node-ignore` (which is used by Nuxt to ignore files).
|
||
*
|
||
* @see [node-ignore](https://github.com/kaelzhang/node-ignore)
|
||
*
|
||
* @example
|
||
* ```js
|
||
* ignoreOptions: {
|
||
* ignorecase: false
|
||
* }
|
||
* ```
|
||
*/
|
||
ignoreOptions: NuxtIgnoreOptions;
|
||
/**
|
||
* Any file in `pages/`, `layouts/`, `middleware/`, and `public/` directories will be ignored during the build process if its filename starts with the prefix specified by `ignorePrefix`. This is intended to prevent certain files from being processed or served in the built application. By default, the `ignorePrefix` is set to '-', ignoring any files starting with '-'.
|
||
*
|
||
*/
|
||
ignorePrefix: string;
|
||
/**
|
||
* More customizable than `ignorePrefix`: all files matching glob patterns specified inside the `ignore` array will be ignored in building.
|
||
*
|
||
*/
|
||
ignore: Array<string>;
|
||
/**
|
||
* The watch property lets you define patterns that will restart the Nuxt dev server when changed.
|
||
*
|
||
* It is an array of strings or regular expressions. Strings should be either absolute paths or relative to the `srcDir` (and the `srcDir` of any layers). Regular expressions will be matched against the path relative to the project `srcDir` (and the `srcDir` of any layers).
|
||
*/
|
||
watch: Array<string | RegExp>;
|
||
/**
|
||
* The watchers property lets you overwrite watchers configuration in your `nuxt.config`.
|
||
*/
|
||
watchers: {
|
||
/**
|
||
* An array of event types, which, when received, will cause the watcher to restart.
|
||
*/
|
||
rewatchOnRawEvents: string[];
|
||
/**
|
||
* `watchOptions` to pass directly to webpack.
|
||
*
|
||
* @see [webpack@4 watch options](https://v4.webpack.js.org/configuration/watch/#watchoptions).
|
||
*/
|
||
webpack: {
|
||
aggregateTimeout: number;
|
||
};
|
||
/**
|
||
* Options to pass directly to `chokidar`.
|
||
*
|
||
* @see [chokidar](https://github.com/paulmillr/chokidar)
|
||
*/
|
||
chokidar: ChokidarOptions;
|
||
};
|
||
/**
|
||
* Hooks are listeners to Nuxt events that are typically used in modules, but are also available in `nuxt.config`.
|
||
*
|
||
* Internally, hooks follow a naming pattern using colons (e.g., build:done).
|
||
* For ease of configuration, you can also structure them as an hierarchical object in `nuxt.config` (as below).
|
||
*
|
||
* @example
|
||
* ```js
|
||
* import fs from 'node:fs'
|
||
* import path from 'node:path'
|
||
* export default {
|
||
* hooks: {
|
||
* build: {
|
||
* done(builder) {
|
||
* const extraFilePath = path.join(
|
||
* builder.nuxt.options.buildDir,
|
||
* 'extra-file'
|
||
* )
|
||
* fs.writeFileSync(extraFilePath, 'Something extra')
|
||
* }
|
||
* }
|
||
* }
|
||
* }
|
||
* ```
|
||
*/
|
||
hooks: NuxtHooks;
|
||
/**
|
||
* Runtime config allows passing dynamic config and environment variables to the Nuxt app context.
|
||
*
|
||
* The value of this object is accessible from server only using `useRuntimeConfig`.
|
||
* It mainly should hold _private_ configuration which is not exposed on the frontend. This could include a reference to your API secret tokens.
|
||
* Anything under `public` and `app` will be exposed to the frontend as well.
|
||
* Keys prefixed with `app` (such as `app` and `appSecret`) are reserved for Nuxt.
|
||
* Values are automatically replaced by matching env variables at runtime, e.g. setting an environment variable `NUXT_API_KEY=my-api-key NUXT_PUBLIC_BASE_URL=/foo/` would overwrite the two values in the example below.
|
||
*
|
||
* @example
|
||
* ```js
|
||
* export default {
|
||
* runtimeConfig: {
|
||
* apiKey: '', // Default to an empty string, automatically set at runtime using process.env.NUXT_API_KEY
|
||
* public: {
|
||
* baseURL: '' // Exposed to the frontend as well.
|
||
* }
|
||
* }
|
||
* }
|
||
* ```
|
||
*/
|
||
runtimeConfig: RuntimeConfig;
|
||
/**
|
||
* Additional app configuration
|
||
*
|
||
* For programmatic usage and type support, you can directly provide app config with this option. It will be merged with `app.config` file as default value.
|
||
*
|
||
* This holds only the inline app config: values from user `app.config` files are resolved at build
|
||
* time and are not present here, so it is typed as `SharedAppConfig` rather than `AppConfig`.
|
||
*/
|
||
appConfig: SharedAppConfig;
|
||
devServer: {
|
||
/**
|
||
* Whether to enable HTTPS.
|
||
*
|
||
*
|
||
* @example
|
||
* ```ts
|
||
* export default defineNuxtConfig({
|
||
* devServer: {
|
||
* https: {
|
||
* key: './server.key',
|
||
* cert: './server.crt'
|
||
* }
|
||
* }
|
||
* })
|
||
* ```
|
||
*/
|
||
https: boolean | {
|
||
key: string;
|
||
cert: string;
|
||
} | {
|
||
pfx: string;
|
||
passphrase: string;
|
||
};
|
||
/**
|
||
* Dev server listening port
|
||
*/
|
||
port: number;
|
||
/**
|
||
* Dev server listening host
|
||
*/
|
||
host: string | undefined;
|
||
/**
|
||
* Hostnames the dev server accepts in the `Host` header, in addition to `localhost`, `*.localhost` and IP addresses.
|
||
*
|
||
* An entry with a leading `.` also allows its subdomains. Set to `true` to allow any host.
|
||
*
|
||
* Includes `devServer.host` and `vite.server.allowedHosts`.
|
||
*/
|
||
allowedHosts: string[] | true;
|
||
/**
|
||
* Listening dev server URL.
|
||
*
|
||
* This should not be set directly as it will always be overridden by the dev server with the full URL (for module and internal use).
|
||
*/
|
||
url: string;
|
||
/**
|
||
* Template to show a loading screen
|
||
*/
|
||
loadingTemplate: (data: {
|
||
loading?: string;
|
||
}) => string;
|
||
/**
|
||
* Base path of the live error channel served in development.
|
||
*
|
||
* Error pages and overlays subscribe to it to update in place, dismiss
|
||
* themselves when the problem is fixed, and open a frame in the editor.
|
||
*
|
||
* @experimental
|
||
*/
|
||
errorChannel: string;
|
||
/**
|
||
* Set CORS options for the dev server
|
||
*/
|
||
cors: "origin" extends keyof H3CorsOptions ? "origin" extends keyof CorsOptions ? CorsOptions | H3CorsOptions : H3CorsOptions : CorsOptions;
|
||
};
|
||
/**
|
||
* `future` is for early opting-in to new features that will become default in a future (possibly major) version of the framework.
|
||
*/
|
||
future: {
|
||
/**
|
||
* Enable early access to future features or flags.
|
||
*
|
||
*/
|
||
compatibilityVersion: 4 | 5;
|
||
/**
|
||
* This enables early access to the experimental multi-app support.
|
||
*
|
||
* @see [Nuxt Issue #21635](https://github.com/nuxt/nuxt/issues/21635)
|
||
*/
|
||
multiApp: boolean;
|
||
/**
|
||
* This enables 'Bundler' module resolution mode for TypeScript, which is the recommended setting for frameworks like Nuxt and Vite.
|
||
*
|
||
* It improves type support when using modern libraries with `exports`.
|
||
* You can set it to false to use the legacy 'Node' mode, which is the default for TypeScript.
|
||
*
|
||
* @see [TypeScript PR implementing `bundler` module resolution](https://github.com/microsoft/TypeScript/pull/51669)
|
||
*/
|
||
typescriptBundlerResolution: boolean;
|
||
};
|
||
/**
|
||
* Some features of Nuxt are available on an opt-in basis, or can be disabled based on your needs.
|
||
*/
|
||
features: {
|
||
/**
|
||
* Inline styles when rendering HTML (currently vite only).
|
||
*
|
||
* You can also pass a function that receives the path of a Vue component and returns a boolean indicating whether to inline the styles for that component.
|
||
*
|
||
* Pages covered by a `noScripts` route rule always have their styles inlined.
|
||
*/
|
||
inlineStyles: boolean | ((id?: string) => boolean);
|
||
/**
|
||
* Stream server logs to the client as you are developing. These logs can be handled in the `dev:ssr-logs` hook.
|
||
*
|
||
* If set to `silent`, the logs will not be printed to the browser console.
|
||
*/
|
||
devLogs: boolean | "silent";
|
||
/**
|
||
* Turn off rendering of Nuxt scripts and JS resource hints. You can also disable scripts more granularly within `routeRules`.
|
||
*
|
||
* If set to 'production' or `true`, JS will be disabled in production mode only.
|
||
*/
|
||
noScripts: "production" | "all" | boolean;
|
||
};
|
||
experimental: {
|
||
/**
|
||
* Type `$fetch` and `useFetch` from the routes the server builder reports, rather than from the
|
||
* responses nitro contributes to `ServerRoutes` through its `InternalApi` interface.
|
||
*
|
||
* The generated route set carries the request shapes a handler validates as well as its
|
||
* response, typed as it arrives over the wire, so a resolving call is typed more tightly than
|
||
* before and `params` is no longer accepted. That is a breaking change, so it is opt-in until
|
||
* `future.compatibilityVersion: 5`, which enables it.
|
||
*
|
||
* Available so that either typing can be selected explicitly while both are supported. It is
|
||
* temporary: from Nuxt 5 the generated route set is the only source and the option is gone.
|
||
*
|
||
* @default false (`true` when `future.compatibilityVersion` is `5` or higher)
|
||
*/
|
||
routeTypedFetch: boolean;
|
||
/**
|
||
* Type requests to routes the server serves, rejecting a path no route answers.
|
||
*
|
||
* Requires `experimental.routeTypedFetch`, which `future.compatibilityVersion: 5` enables.
|
||
* While requests are typed from nitro's `InternalApi` there is nothing for this to constrain,
|
||
* and the setting is resolved to `false`.
|
||
*
|
||
* Nuxt types `$fetch` and `useFetch` from the routes your server builder will serve, so a
|
||
* request is typed by the handler that answers it. By default an unrecognised path is still
|
||
* accepted and resolves to `unknown`, because Nuxt cannot see every way a request may be
|
||
* answered: nitro middleware, a `routeRules` proxy or a catch-all handler can answer anything.
|
||
*
|
||
* - `false` - a path Nuxt does not recognise is accepted and resolves to `unknown`.
|
||
* - `true` - only routes the server builder reports are accepted. A typo is an error naming the
|
||
* path and method that matched nothing.
|
||
* - `'isomorphic'` - as `true`, and pages are included as `GET` routes returning `string`, so
|
||
* `$fetch('/about')` is typed by the route the Vue router serves rather than rejected.
|
||
*
|
||
* Set this only where your routing is enumerable. An app with a catch-all page under
|
||
* `'isomorphic'` matches every path, which is correct but means the setting constrains nothing.
|
||
*
|
||
* @default false
|
||
*/
|
||
strictRouteTypes: boolean | "isomorphic";
|
||
/**
|
||
* Enable to use experimental decorators in Nuxt and Nitro.
|
||
*
|
||
* @default false
|
||
* @see https://github.com/tc39/proposal-decorators
|
||
*/
|
||
decorators: boolean;
|
||
/**
|
||
* Set to true to generate an async entry point for the Vue bundle (for module federation support).
|
||
*
|
||
* @default false
|
||
*/
|
||
asyncEntry: boolean;
|
||
/**
|
||
* Externalize `vue`, `@vue/*` and `vue-router` when building.
|
||
*
|
||
* @default true
|
||
* @see [Nuxt Issue #13632](https://github.com/nuxt/nuxt/issues/13632)
|
||
*/
|
||
externalVue: boolean;
|
||
/**
|
||
* Enable accessing `appConfig` from server routes.
|
||
*
|
||
* @default true
|
||
* @deprecated This option is not recommended.
|
||
*/
|
||
serverAppConfig: boolean;
|
||
/**
|
||
* Emit `app:chunkError` hook when there is an error loading vite/webpack chunks.
|
||
*
|
||
* By default, Nuxt will also perform a reload of the new route when a chunk fails to load when navigating to a new route (`automatic`).
|
||
* Setting `automatic-immediate` will lead Nuxt to perform a reload of the current route right when a chunk fails to load (instead of waiting for navigation).
|
||
* You can disable automatic handling by setting this to `false`, or handle chunk errors manually by setting it to `manual`.
|
||
*
|
||
* @default 'automatic'
|
||
* @see [Nuxt PR #19038](https://github.com/nuxt/nuxt/pull/19038)
|
||
*/
|
||
emitRouteChunkError: false | "manual" | "automatic" | "automatic-immediate";
|
||
/**
|
||
* By default the route object returned by the auto-imported `useRoute()` composable is kept in sync with the current page in view in `<NuxtPage>`. This is not true for `vue-router`'s exported `useRoute` or for the default `$route` object available in your Vue templates.
|
||
*
|
||
* By enabling this option a mixin will be injected to keep the `$route` template object in sync with Nuxt's managed `useRoute()`.
|
||
*
|
||
* @default true
|
||
*/
|
||
templateRouteInjection: boolean;
|
||
/**
|
||
* Whether to restore Nuxt app state from `sessionStorage` when reloading the page after a chunk error or manual `reloadNuxtApp()` call.
|
||
*
|
||
* To avoid hydration errors, it will be applied only after the Vue app has been mounted, meaning there may be a flicker on initial load.
|
||
* Consider carefully before enabling this as it can cause unexpected behavior, and consider providing explicit keys to `useState` as auto-generated keys may not match across builds.
|
||
*
|
||
* @default false
|
||
*/
|
||
restoreState: boolean;
|
||
/**
|
||
* Render JSON payloads with support for revivifying complex types.
|
||
*
|
||
* @default true
|
||
*/
|
||
renderJsonPayloads: boolean;
|
||
/**
|
||
* Disable vue server renderer endpoint within nitro.
|
||
*
|
||
* @default false
|
||
*/
|
||
noVueServer: boolean;
|
||
/**
|
||
* Controls how payload data is delivered for prerendered and cached (ISR/SWR) pages.
|
||
*
|
||
* - `'client'` - Payload is inlined in HTML for the initial server render, and extracted to
|
||
* `_payload.json` files for client-side navigation. This avoids a separate request on
|
||
* initial load while still enabling efficient client-side navigation.
|
||
* - `true` - Payload is extracted to a separate `_payload.json` file for both the initial
|
||
* server render and client-side navigation.
|
||
* - `false` - Payload extraction is disabled entirely. Payload is always inlined in HTML and
|
||
* no `_payload.json` files are generated.
|
||
*
|
||
* `@default` true (or 'client' when compatibilityVersion >= 5)
|
||
*/
|
||
payloadExtraction: "client" | boolean | undefined;
|
||
/**
|
||
* Render the error page in the Nuxt renderer itself when a server render fails, rather than
|
||
* handing the error to the server runtime and re-entering the renderer over an internal request.
|
||
*
|
||
* The error page is rendered in process, on the same request event, so the response keeps the
|
||
* headers and cookies the failed render had already written.
|
||
*
|
||
* @default true (when compatibilityVersion >= 5)
|
||
*/
|
||
inlineErrorRendering: boolean;
|
||
/**
|
||
* Server-render static error pages (such as `404.html`) when prerendering, rather than emitting an empty SPA shell.
|
||
*
|
||
* Pass an array of status codes between 400 and 599 to control which error pages are generated. `true` is equivalent to `[404]`.
|
||
*
|
||
* @default false
|
||
*/
|
||
prerenderErrorPages: boolean | number[];
|
||
/**
|
||
* Respond with an early 404 error for requests whose path cannot match any page route,
|
||
* without loading the Vue app, its plugins or middleware on the server.
|
||
*
|
||
* Page routes (including aliases) are converted to route patterns at build time and
|
||
* requests are checked against them before server-side rendering begins.
|
||
*
|
||
* This is opt-in as it can break apps that rely on runtime routing: pages added
|
||
* dynamically with `router.addRoute()` (on the server or the client), or route
|
||
* middleware that redirects unknown paths to existing ones. It also applies to
|
||
* `ssr: false` routes, which respond with a 404 error rather than the SPA shell when
|
||
* no page can match. The option is disabled automatically in development, when using
|
||
* `hashMode`, with a root-level catch-all page, and when a custom `app/router.options`
|
||
* file may modify `routes`.
|
||
*
|
||
* @default false
|
||
*/
|
||
early404: boolean;
|
||
/**
|
||
* Whether to enable the experimental `<NuxtClientFallback>` component for rendering content on the client if there's an error in SSR.
|
||
*
|
||
* @default false
|
||
*/
|
||
clientFallback: boolean;
|
||
/**
|
||
* Enable cross-origin prefetch using the Speculation Rules API.
|
||
*
|
||
* @default false
|
||
*/
|
||
crossOriginPrefetch: boolean;
|
||
/**
|
||
* Enable View Transition API integration with client-side router.
|
||
*
|
||
* @default false
|
||
* @see [View Transitions API](https://developer.chrome.com/docs/web-platform/view-transitions)
|
||
*/
|
||
viewTransition: ViewTransitionOptions | ViewTransitionOptions["enabled"];
|
||
/**
|
||
* Write early hints when using node server.
|
||
*
|
||
* @default false
|
||
* @note nginx does not support 103 Early hints in the current version.
|
||
*/
|
||
writeEarlyHints: boolean;
|
||
/**
|
||
* Experimental component islands support with `<NuxtIsland>` and `.island.vue` files.
|
||
*
|
||
* By default it is set to 'auto', which means it will be enabled only when there are islands, server components or server pages in your app.
|
||
*
|
||
* @default 'auto'
|
||
*/
|
||
componentIslands: true | "auto" | "local" | "local+remote" | Partial<{
|
||
remoteIsland: boolean;
|
||
selectiveClient: boolean | "deep";
|
||
}> | false;
|
||
/**
|
||
* Resolve `~`, `~~`, `@` and `@@` aliases located within layers with respect to their layer source and root directories.
|
||
*
|
||
* @default true
|
||
*/
|
||
localLayerAliases: boolean;
|
||
/**
|
||
* Enable the new experimental typed router using vue-router.
|
||
*
|
||
* This is enabled by default with compatibility version 5.
|
||
*
|
||
* @default false
|
||
*/
|
||
typedPages: boolean;
|
||
/**
|
||
* Load a client-side navigation that matches no page route as a full document, so the
|
||
* server can respond with a public asset, a server route or its 404 page.
|
||
*
|
||
* @default true
|
||
*/
|
||
serverPathFallback: boolean;
|
||
/**
|
||
* Use app manifests to respect route rules on client-side.
|
||
*
|
||
* @default true
|
||
*/
|
||
appManifest: boolean;
|
||
/**
|
||
* Set the time interval (in ms) to check for new builds. Disabled when `experimental.appManifest` is `false`.
|
||
*
|
||
* Set to `false` to disable.
|
||
* @default 3600000 (1 hour)
|
||
*/
|
||
checkOutdatedBuildInterval: number | false;
|
||
/**
|
||
* Set an alternative watcher that will be used as the watching service for Nuxt.
|
||
*
|
||
* Nuxt uses 'chokidar-granular' if your source directory is the same as your root directory . This will ignore top-level directories (like `node_modules` and `.git`) that are excluded from watching.
|
||
* You can set this instead to `parcel` to use `@parcel/watcher`, which may improve performance in large projects or on Windows platforms.
|
||
* You can also set this to `chokidar` to watch all files in your source directory.
|
||
*
|
||
* Set to `'builder'` to reuse the active builder's own file watcher (e.g. Vite's `server.watcher`) instead of starting a second one. If the active builder does not provide a watcher, Nuxt falls back to its default selection.
|
||
*
|
||
* @see [chokidar](https://github.com/paulmillr/chokidar)
|
||
*
|
||
* @see [@parcel/watcher](https://github.com/parcel-bundler/watcher)
|
||
*
|
||
* @default 'builder' if `future.compatibilityVersion` >= 5, otherwise 'chokidar-granular' if `srcDir` is the same as `rootDir`, otherwise 'chokidar'
|
||
*/
|
||
watcher: "chokidar" | "parcel" | "chokidar-granular" | "builder";
|
||
/**
|
||
* Enable native async context to be accessible for nested composables
|
||
*
|
||
* @default false
|
||
* @see [Nuxt PR #20918](https://github.com/nuxt/nuxt/pull/20918)
|
||
*/
|
||
asyncContext: boolean;
|
||
/**
|
||
* Use new experimental head optimisations:
|
||
*
|
||
* - Add the capo.js head plugin in order to render tags in of the head in a more performant way. - Uses the hash hydration plugin to reduce initial hydration
|
||
*
|
||
* @deprecated CAPO sorting is now the default in unhead v3. Set `unhead.legacy: true` to opt out
|
||
* temporarily on compat v4.
|
||
* @default true
|
||
* @see [Nuxt Discussion #22632](https://github.com/nuxt/nuxt/discussions/22632)
|
||
*/
|
||
headNext: boolean;
|
||
/**
|
||
* Allow defining `routeRules` directly within your `~/pages` directory using `defineRouteRules`.
|
||
*
|
||
* Rules are converted (based on the path) and applied for server requests. For example, a rule defined in `~/pages/foo/bar.vue` will be applied to `/foo/bar` requests. A rule in `~/pages/foo/[id].vue` will be applied to `/foo/**` requests.
|
||
* For more control, such as if you are using a custom `path` or `alias` set in the page's `definePageMeta`, you should set `routeRules` directly within your `nuxt.config`.
|
||
*
|
||
* @default false
|
||
*/
|
||
inlineRouteRules: boolean;
|
||
/**
|
||
* Allow exposing some route metadata defined in `definePageMeta` at build-time to modules (alias, name, path, redirect, props, middleware).
|
||
*
|
||
* This only works with static or strings/arrays rather than variables or conditional assignment.
|
||
*
|
||
* @default 'after-resolve'
|
||
* @see [Nuxt Issues #24770](https://github.com/nuxt/nuxt/issues/24770)
|
||
*/
|
||
scanPageMeta: boolean | "after-resolve";
|
||
/**
|
||
* Configure additional keys to extract from the page metadata when using `scanPageMeta`.
|
||
*
|
||
* This allows modules to access additional metadata from the page metadata. It's recommended to augment the NuxtPage types with your keys.
|
||
*
|
||
* @default []
|
||
*/
|
||
extraPageMetaExtractionKeys: string[];
|
||
/**
|
||
* Extract every JSON-serializable `definePageMeta` property into the generated route record,
|
||
* rather than only the keys Nuxt reads at build time.
|
||
*
|
||
* When every property of a page's `definePageMeta` can be resolved statically, the generated
|
||
* route no longer imports the page's macro module at all, removing one module per page from
|
||
* the dev module graph. Properties whose values cannot be serialized are unaffected and are
|
||
* still resolved by the macro module at runtime.
|
||
*
|
||
* This has no effect when `experimental.scanPageMeta` is `false`, as the route record does
|
||
* not override the macro module in that case.
|
||
*
|
||
* @default false
|
||
* @default true with compatibilityVersion >= 5
|
||
*/
|
||
extractSerializablePageMeta: boolean;
|
||
/**
|
||
* Automatically share payload _data_ between pages that are prerendered. This can result in a significant performance improvement when prerendering sites that use `useAsyncData` or `useFetch` and fetch the same data in different pages.
|
||
*
|
||
* It is particularly important when enabling this feature to make sure that any unique key of your data is always resolvable to the same data. For example, if you are using `useAsyncData` to fetch data related to a particular page, you should provide a key that uniquely matches that data. (`useFetch` should do this automatically for you.)
|
||
*
|
||
* @default true
|
||
* @example
|
||
* ```ts
|
||
* // This would be unsafe in a dynamic page (e.g. `[slug].vue`) because the route slug makes a difference
|
||
* // to the data fetched, but Nuxt can't know that because it's not reflected in the key.
|
||
* const route = useRoute()
|
||
* const { data } = await useAsyncData(async () => {
|
||
* return await $fetch(`/api/my-page/${route.params.slug}`)
|
||
* })
|
||
* // Instead, you should use a key that uniquely identifies the data fetched.
|
||
* const { data } = await useAsyncData(route.params.slug, async () => {
|
||
* return await $fetch(`/api/my-page/${route.params.slug}`)
|
||
* })
|
||
* ```
|
||
*/
|
||
sharedPrerenderData: boolean;
|
||
/**
|
||
* Enables CookieStore support to listen for cookie updates (if supported by the browser) and refresh `useCookie` ref values.
|
||
*
|
||
* @default true
|
||
* @see [CookieStore](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore)
|
||
*/
|
||
cookieStore: boolean;
|
||
/**
|
||
* Enable experimental Vite Environment API
|
||
* @see [Vite Environment API](https://vite.dev/guide/api-environment#environment-api)
|
||
* @default false
|
||
* @default true with compatibilityVersion >= 5
|
||
*/
|
||
viteEnvironmentApi: boolean;
|
||
/**
|
||
* This allows specifying the default options for core Nuxt components and composables.
|
||
*
|
||
* These options will likely be moved elsewhere in the future, such as into `app.config` or into the `app/` directory.
|
||
*/
|
||
defaults: {
|
||
/**
|
||
* @default { componentName: 'NuxtLink', prefetch: true, prefetchOn: { visibility: true }}
|
||
*/
|
||
nuxtLink: NuxtLinkOptions;
|
||
/**
|
||
* Options that apply to `useAsyncData` (and also therefore `useFetch`)
|
||
* @default { deep: false }
|
||
*/
|
||
useAsyncData: {
|
||
deep: boolean;
|
||
};
|
||
/**
|
||
* Options that apply to `useState` and `clearNuxtState`.
|
||
* @default { resetOnClear: false }
|
||
* @default { resetOnClear: true } with compatibilityVersion >= 5
|
||
*/
|
||
useState: {
|
||
/**
|
||
* When `true`, `clearNuxtState` will reset state to its initial value (provided by the `init`
|
||
* function of `useState`) instead of setting it to `undefined`.
|
||
*
|
||
* This aligns `clearNuxtState` behavior with `clearNuxtData`, which already resets to defaults.
|
||
*
|
||
* @default false
|
||
* @default true with compatibilityVersion >= 5
|
||
*/
|
||
resetOnClear: boolean;
|
||
};
|
||
useFetch: {
|
||
/** Request timeout in milliseconds. */
|
||
timeout?: number;
|
||
/** Number of times to retry a failed request, or `false` to disable retries. */
|
||
retry?: number | false;
|
||
/** Delay between retries in milliseconds. */
|
||
retryDelay?: number | ((context: any) => number);
|
||
/** Response status codes that trigger a retry. */
|
||
retryStatusCodes?: number[];
|
||
};
|
||
};
|
||
/**
|
||
* Automatically polyfill Node.js imports in the client build using `unenv`.
|
||
*
|
||
* @default false
|
||
* @see [unenv](https://github.com/unjs/unenv)
|
||
*
|
||
* **Note:** To make globals like `Buffer` work in the browser, you need to manually inject them.
|
||
*
|
||
* ```ts
|
||
* import { Buffer } from 'node:buffer'
|
||
*
|
||
* globalThis.Buffer = globalThis.Buffer || Buffer
|
||
* ```
|
||
*/
|
||
clientNodeCompat: boolean;
|
||
/**
|
||
* Wait for a single animation frame before navigation, which gives an opportunity for the browser to repaint, acknowledging user interaction.
|
||
*
|
||
* It can reduce INP when navigating on prerendered routes.
|
||
*
|
||
* @default true
|
||
*/
|
||
navigationRepaint: boolean;
|
||
/**
|
||
* Transform top-level `await navigateTo()` calls in `<script setup>` into an early return
|
||
* from the compiled `setup()` function when the navigation succeeds.
|
||
*
|
||
* This stops execution of the rest of your setup code after a redirect, and renders
|
||
* a placeholder comment while the navigation proceeds, rather than continuing to run
|
||
* code (and potentially navigating again) after `navigateTo` has been called.
|
||
* @default false
|
||
* @default true with compatibilityVersion >= 5
|
||
* @see [Nuxt Issue #23698](https://github.com/nuxt/nuxt/issues/23698)
|
||
*/
|
||
navigateToEarlyReturn: boolean;
|
||
/**
|
||
* Cache Nuxt/Nitro build artifacts based on a hash of the configuration and source files.
|
||
*
|
||
* This only works for source files within `srcDir` and `serverDir` for the Vue/Nitro parts of your app.
|
||
* @default false
|
||
*/
|
||
buildCache: boolean;
|
||
/**
|
||
* Ensure that auto-generated Vue component names match the full component name you would use to auto-import the component.
|
||
* @default true
|
||
*/
|
||
normalizeComponentNames: boolean;
|
||
/**
|
||
* Ensure that page component names match their route names.
|
||
*
|
||
* This is useful when using `<KeepAlive>` with `include`/`exclude` filters, as Vue's
|
||
* `<KeepAlive>` relies on the component `name` option to identify components.
|
||
* Without this, page components may have generic names (like `index`) that don't
|
||
* correspond to their route names, making name-based `<KeepAlive>` filtering unreliable.
|
||
* @default false
|
||
* @default true with compatibilityVersion >= 5
|
||
*/
|
||
normalizePageNames: boolean;
|
||
/**
|
||
* Keep showing the spa-loading-template until suspense:resolve
|
||
*
|
||
* @default 'body'
|
||
* @see [Nuxt Issues #21721](https://github.com/nuxt/nuxt/issues/21721)
|
||
*/
|
||
spaLoadingTemplateLocation: "body" | "within";
|
||
/**
|
||
* Enable timings for Nuxt application hooks in the performance panel of Chromium-based browsers.
|
||
*
|
||
* This feature adds performance markers for Nuxt hooks, allowing you to track their execution time in the browser's Performance tab. This is particularly useful for debugging performance issues.
|
||
*
|
||
* @example
|
||
* ```ts
|
||
* // nuxt.config.ts
|
||
* export default defineNuxtConfig({
|
||
* experimental: {
|
||
* // Enable performance markers for Nuxt hooks in browser devtools
|
||
* browserDevtoolsTiming: true
|
||
* }
|
||
* })
|
||
* ```
|
||
*
|
||
* @default {isDev}
|
||
*
|
||
* @see [PR #29922](https://github.com/nuxt/nuxt/pull/29922)
|
||
*
|
||
* @see [Chrome DevTools Performance API](https://developer.chrome.com/docs/devtools/performance/extension#tracks)
|
||
*/
|
||
browserDevtoolsTiming: boolean;
|
||
/**
|
||
* Enable integration with Chrome DevTools Workspaces
|
||
* for Nuxt projects.
|
||
*
|
||
* @default true
|
||
* @see [Chrome DevTools Project Settings](https://docs.google.com/document/d/1rfKPnxsNuXhnF7AiQZhu9kIwdiMS5hnAI05HBwFuBSM/edit)
|
||
*/
|
||
chromeDevtoolsProjectSettings: boolean;
|
||
/**
|
||
* Record mutations to `nuxt.options` in module context, helping to debug configuration changes made by modules during the Nuxt initialization phase.
|
||
*
|
||
* When enabled, Nuxt will track which modules modify configuration options, making it easier to trace unexpected configuration changes.
|
||
*
|
||
* @default false
|
||
* @example
|
||
* ```ts
|
||
* // nuxt.config.ts
|
||
* export default defineNuxtConfig({
|
||
* experimental: {
|
||
* // Enable tracking of config mutations by modules
|
||
* debugModuleMutation: true
|
||
* }
|
||
* })
|
||
* ```
|
||
*
|
||
* @see [PR #30555](https://github.com/nuxt/nuxt/pull/30555)
|
||
*/
|
||
debugModuleMutation: boolean;
|
||
/**
|
||
* Enable automatic configuration of hydration strategies for `<Lazy>` components.
|
||
*
|
||
* This feature intelligently determines when to hydrate lazy components based on visibility, idle time, or other triggers, improving performance by deferring hydration of components until they're needed.
|
||
*
|
||
* @default true
|
||
* @example
|
||
* ```ts
|
||
* // nuxt.config.ts
|
||
* export default defineNuxtConfig({
|
||
* experimental: {
|
||
* lazyHydration: true // Enable smart hydration strategies for Lazy components
|
||
* }
|
||
* })
|
||
*
|
||
* // In your Vue components
|
||
* <template>
|
||
* <Lazy>
|
||
* <ExpensiveComponent />
|
||
* </Lazy>
|
||
* </template>
|
||
* ```
|
||
*
|
||
* @see [PR #26468](https://github.com/nuxt/nuxt/pull/26468)
|
||
*/
|
||
lazyHydration: boolean;
|
||
/**
|
||
* Disable resolving imports into Nuxt templates from the path of the module that added the template.
|
||
*
|
||
* By default, Nuxt attempts to resolve imports in templates relative to the module that added them. Setting this to `false` disables this behavior, which may be useful if you're experiencing resolution conflicts in certain environments.
|
||
*
|
||
* @default true
|
||
* @example
|
||
* ```ts
|
||
* // nuxt.config.ts
|
||
* export default defineNuxtConfig({
|
||
* experimental: {
|
||
* // Disable template import resolution from module path
|
||
* templateImportResolution: false
|
||
* }
|
||
* })
|
||
* ```
|
||
*
|
||
* @see [PR #31175](https://github.com/nuxt/nuxt/pull/31175)
|
||
*/
|
||
templateImportResolution: boolean;
|
||
/**
|
||
* Whether to clean up Nuxt static and asyncData caches on route navigation.
|
||
*
|
||
* Nuxt will automatically purge cached data from `useAsyncData` and `nuxtApp.static.data`. This helps prevent memory leaks and ensures fresh data is loaded when needed, but it is possible to disable it.
|
||
* @default true
|
||
* @example
|
||
* ```ts
|
||
* // nuxt.config.ts
|
||
* export default defineNuxtConfig({
|
||
* experimental: {
|
||
* // Disable automatic cache cleanup (default is true)
|
||
* purgeCachedData: false
|
||
* }
|
||
* })
|
||
* ```
|
||
*
|
||
* @see [PR #31379](https://github.com/nuxt/nuxt/pull/31379)
|
||
*/
|
||
purgeCachedData: boolean;
|
||
/**
|
||
* When a `<NuxtLink>` is prefetched and the destination route has payload extraction enabled (the default for prerendered and cached routes), forward any `<link rel="preload">` hints that the destination set via `useHead` (or via modules like `@nuxt/image`'s `<NuxtImg preload>`) into the current document.
|
||
*
|
||
* The forwarded links are downgraded from `rel="preload"` to `rel="prefetch"` so they don't compete with the current page's critical resources. Only user-defined head tags are forwarded; build-time JS/CSS chunk preloads are not.
|
||
*
|
||
* @default false
|
||
* @see [Issue #34953](https://github.com/nuxt/nuxt/issues/34953)
|
||
*/
|
||
prefetchPreloadTags: boolean;
|
||
/**
|
||
* Whether to call and use the result from `getCachedData` on manual refresh for `useAsyncData` and `useFetch`.
|
||
*
|
||
* @default true
|
||
*/
|
||
granularCachedData: boolean;
|
||
/**
|
||
* Apply `serialize: false` by default to `useAsyncData` and `useFetch` calls made within components lazily hydrated with `hydrate-never`, keeping their data out of the `__NUXT_DATA__` payload.
|
||
*
|
||
* An explicit `serialize` option always takes precedence. Note that data shared with other components via a common key follows the options of whichever call creates the shared entry first.
|
||
* @default false
|
||
*/
|
||
stripNeverHydratedData: boolean;
|
||
/**
|
||
* Whether to run `useFetch` when the key changes, even if it is set to `immediate: false` and it has not been triggered yet.
|
||
*
|
||
* `useFetch` and `useAsyncData` will always run when the key changes if `immediate: true` or if it has been already triggered.
|
||
*
|
||
* @default false
|
||
*/
|
||
alwaysRunFetchOnKeyChange: boolean;
|
||
/**
|
||
* Whether to parse `error.data` when rendering a server error page.
|
||
*
|
||
* @default true
|
||
*/
|
||
parseErrorData: boolean;
|
||
/**
|
||
* Whether Nuxt should stop if a Nuxt module is incompatible.
|
||
*
|
||
* @default false
|
||
*/
|
||
enforceModuleCompatibility: boolean;
|
||
/**
|
||
* For `useAsyncData` and `useFetch`, whether `pending` should be `true` when data has not yet started to be fetched.
|
||
*
|
||
* @default false
|
||
*/
|
||
pendingWhenIdle: boolean;
|
||
/**
|
||
* Whether to improve chunk stability by using an import map to resolve the entry chunk of the bundle.
|
||
*
|
||
* @default true
|
||
*/
|
||
entryImportMap: boolean;
|
||
/**
|
||
* Extract async data handler functions into separate chunks for better performance and caching.
|
||
*
|
||
* When enabled, handler functions passed to `useAsyncData` and `useLazyAsyncData` will be extracted
|
||
* into separate chunks and dynamically imported, allowing for better code splitting and caching.
|
||
*
|
||
* @default false
|
||
* @experimental This is an experimental feature and API may change in the future.
|
||
*/
|
||
extractAsyncDataHandlers: boolean;
|
||
/**
|
||
* Whether to enable `@dxup/nuxt` module for better TypeScript DX.
|
||
*
|
||
* @default false
|
||
* @see https://github.com/KazariEX/dxup
|
||
*/
|
||
typescriptPlugin: boolean;
|
||
/**
|
||
* Whether to add a middleware to handle changes of base URL at runtime (has a performance overhead)
|
||
*
|
||
* This option only has effect when using Nitro v3+.
|
||
* @default false
|
||
*/
|
||
runtimeBaseURL: boolean;
|
||
/**
|
||
* Whether to enable a compatibility layer for Nitro auto imports.
|
||
* We recommend migrating to direct imports instead.
|
||
* @default true
|
||
* @default false with compatibilityVersion >= 5
|
||
*/
|
||
nitroAutoImports: boolean;
|
||
/**
|
||
* Run Nitro as a Vite environment using the `nitro/vite` plugin instead of
|
||
* Nitro's own Rolldown pipeline.
|
||
*
|
||
* Not supported for Nuxt 3/4.
|
||
* @default false
|
||
*/
|
||
nitroViteEnvironment: boolean;
|
||
/**
|
||
* Enable SSR streaming to improve Time to First Byte (TTFB).
|
||
*
|
||
* When enabled, the server sends the HTML shell (head, styles, preload hints)
|
||
* immediately and streams the rendered body content progressively.
|
||
*
|
||
* Streaming is automatically disabled for bot/crawler user agents (see
|
||
* `botRegex`) to ensure search engines receive fully-rendered HTML. You can
|
||
* opt a route out of streaming via `routeRules` with `streaming: false`.
|
||
*
|
||
* Set to `true` to enable with defaults, or pass an object to configure options.
|
||
*
|
||
* @default false
|
||
* @see https://github.com/nuxt/nuxt/issues/4753
|
||
*/
|
||
ssrStreaming: boolean | {
|
||
enabled?: boolean;
|
||
/**
|
||
* A regular expression matching bot/crawler user agents that should *not*
|
||
* receive a streamed response.
|
||
*
|
||
* When the `user-agent` header of a request matches this pattern, streaming
|
||
* is disabled for that request and the fully-rendered (buffered) HTML is
|
||
* sent instead, for SEO safety. Requests that do not match are streamed.
|
||
*
|
||
* Setting this replaces the default pattern rather than extending it, so
|
||
* include any built-in crawlers you still want to opt out of streaming.
|
||
*
|
||
* @default /bot\b|crawl|spider|slurp|facebookexternalhit|google\b|bing\b|yandex\b|baidu\b|duckduck/i
|
||
*/
|
||
botRegex?: RegExp;
|
||
};
|
||
/**
|
||
* Whether `callHook` always returns a `Promise`, wrapping synchronous hook results.
|
||
*
|
||
* Hookable v6 may return `void` instead of `Promise<void>` when there are no registered
|
||
* hooks or all hooks are synchronous. When this option is enabled, Nuxt wraps `callHook`
|
||
* with `Promise.resolve()` so that `.then()` and `.catch()` chaining always works.
|
||
*
|
||
* Set to `false` for better performance if your code and modules use `await` with `callHook`.
|
||
* @default true
|
||
* @default false with compatibilityVersion >= 5
|
||
*/
|
||
asyncCallHook: boolean;
|
||
/**
|
||
* Whether to use comment nodes instead of `<div>` elements as placeholders for client-only
|
||
* components during server-side rendering.
|
||
*
|
||
* When enabled, `.client.vue` components and `createClientOnly()` wrappers render an HTML
|
||
* comment (`<!--placeholder-->`) on the server instead of an empty `<div>`. This fixes a
|
||
* Vue hydration issue where scoped styles may not be applied when the placeholder `<div>`
|
||
* and the actual component root share the same tag name.
|
||
*
|
||
* Note: enabling this means attributes (class, style, etc.) passed to `.client.vue`
|
||
* components will not be rendered in the SSR HTML. If you need styled placeholders,
|
||
* use `<ClientOnly>` with a `#fallback` slot instead.
|
||
* @default false
|
||
* @default true with compatibilityVersion >= 5
|
||
*/
|
||
clientNodePlaceholder: boolean;
|
||
/**
|
||
* When enabled, Nuxt will clear build-related hooks after bundling, freeing
|
||
* memory before the Nitro build. Disable this if you need to call `build()`
|
||
* multiple times on the same Nuxt instance (e.g. in benchmarks).
|
||
*/
|
||
clearBuildHooks: boolean;
|
||
};
|
||
/**
|
||
*
|
||
* @private
|
||
*/
|
||
_majorVersion: number;
|
||
/**
|
||
* The nitro major version the host Nuxt builds against, set before any module
|
||
* runs so `@nuxt/kit` version detection is reliable during module setup.
|
||
* @private
|
||
*/
|
||
_nitroMajor: number;
|
||
/**
|
||
*
|
||
* @private
|
||
*/
|
||
_prepare: boolean;
|
||
/**
|
||
*
|
||
* @private
|
||
*/
|
||
_requiredModules: Record<string, boolean>;
|
||
/**
|
||
*
|
||
* @private
|
||
*/
|
||
_loadOptions: {
|
||
dotenv?: boolean | NuxtDotenvOptions;
|
||
envName?: string | false;
|
||
};
|
||
/**
|
||
*
|
||
* @private
|
||
*/
|
||
_nuxtConfigFile: string;
|
||
/**
|
||
*
|
||
* @private
|
||
*/
|
||
_nuxtConfigFiles: Array<string>;
|
||
/**
|
||
*
|
||
* @private
|
||
*/
|
||
appDir: string;
|
||
/**
|
||
*
|
||
* @private
|
||
*/
|
||
_installedModules: Array<{
|
||
meta: ModuleMeta;
|
||
module: NuxtModule;
|
||
timings?: Record<string, number | undefined>;
|
||
entryPath?: string;
|
||
}>;
|
||
/**
|
||
*
|
||
* @private
|
||
*/
|
||
_modules: Array<any>;
|
||
/**
|
||
* Sources of the pages that are served without scripts, as registered in `ssrContext.modules`.
|
||
*
|
||
* @private
|
||
*/
|
||
_noScriptsPageSources: Array<string>;
|
||
/**
|
||
* Configuration for Nuxt's server builder.
|
||
*
|
||
* `'nitro'` and `'vite'` are shorthands for `'@nuxt/nitro-server'` (a full server
|
||
* runtime) and `'@nuxt/vite-server'` (a static, client-only SPA).
|
||
*/
|
||
server: {
|
||
builder?: "@nuxt/nitro-server" | "@nuxt/vite-server" | "nitro" | "vite" | (string & {}) | {
|
||
bundle: (nuxt: Nuxt) => Promise<void>;
|
||
};
|
||
};
|
||
/**
|
||
* Configuration of the configured `server.builder`, whose shape that builder declares.
|
||
*
|
||
* @see [Nitro configuration docs](https://nitro.build/config)
|
||
*/
|
||
nitro: ResolveNuxtNitroConfig<NitroConfig>;
|
||
/**
|
||
* Global route options applied to matching server routes.
|
||
*
|
||
* @experimental This is an experimental feature and API may change in the future.
|
||
*
|
||
* @see [Nitro route rules documentation](https://nitro.build/config#routerules)
|
||
*/
|
||
routeRules: Record<string, RouteRuleConfig> | undefined;
|
||
/**
|
||
* Prerender options applied by any `server.builder`.
|
||
*
|
||
* Builder-specific options can be set in `nitro.prerender`.
|
||
*
|
||
* @see [Prerendering documentation](https://nuxt.com/docs/getting-started/prerendering)
|
||
*/
|
||
prerender: PrerenderOptions;
|
||
/**
|
||
* Server handlers registered with the configured `server.builder`.
|
||
*
|
||
* Each handler accepts the following options:
|
||
* - handler: The path to the file defining the handler. - route: The route under which the handler is available. This follows the conventions of [rou3](https://github.com/h3js/rou3). - method: The HTTP method of requests that should be handled. - middleware: Specifies whether it is a middleware handler. - lazy: Specifies whether to use lazy loading to import the handler.
|
||
*
|
||
* @see [`server/` directory documentation](https://nuxt.com/docs/4.x/directory-structure/server)
|
||
*
|
||
* @note Files from `server/api`, `server/middleware` and `server/routes` will be automatically registered by Nuxt.
|
||
*
|
||
* @example
|
||
* ```js
|
||
* serverHandlers: [
|
||
* { route: '/path/foo/**:name', handler: '#server/foohandler.ts' }
|
||
* ]
|
||
* ```
|
||
*/
|
||
serverHandlers: ServerHandler[];
|
||
/**
|
||
* Development-only server handlers registered with the configured `server.builder`.
|
||
*
|
||
* @see [Nitro server routes documentation](https://nitro.build/guide/routing)
|
||
*/
|
||
devServerHandlers: DevServerHandler[];
|
||
/**
|
||
* Plugins registered with the configured `server.builder` through `addNitroPlugin()`,
|
||
* which run once when the server starts. Configure `nitro.plugins` instead.
|
||
*
|
||
* @private
|
||
*/
|
||
_serverPlugins: ServerPlugin[];
|
||
/**
|
||
* Enable [diagnostics-channel](https://nodejs.org/api/diagnostics_channel.html)
|
||
* tracing for Nuxt-owned subsystems, and forward the channels the configured
|
||
* `server.builder` provides.
|
||
*
|
||
* @experimental Channel names, payload shapes, and option keys may change.
|
||
*
|
||
* @see [Untracing naming registry](https://github.com/unjs/untracing)
|
||
*/
|
||
tracingChannel: boolean | TracingChannelOptions;
|
||
postcss: {
|
||
/**
|
||
* A strategy for ordering PostCSS plugins.
|
||
*/
|
||
order: "cssnanoLast" | "autoprefixerLast" | "autoprefixerAndCssnanoLast" | string[] | ((names: string[]) => string[]);
|
||
/**
|
||
* Options for configuring PostCSS plugins.
|
||
*
|
||
* @see [PostCSS docs](https://postcss.org/)
|
||
*/
|
||
plugins: Record<string, unknown> & {
|
||
autoprefixer?: false | Options$2;
|
||
cssnano?: false | Options$3;
|
||
};
|
||
};
|
||
router: {
|
||
/**
|
||
* Additional router options passed to `vue-router`. On top of the options for `vue-router`, Nuxt offers additional options to customize the router (see below).
|
||
*
|
||
* @note Only JSON serializable options should be passed by Nuxt config.
|
||
* For more control, you can use `app/router.options.ts` file.
|
||
*
|
||
* @note `sensitive` defaults to `true` with `future.compatibilityVersion >= 5`.
|
||
*
|
||
* @see [Vue Router documentation](https://router.vuejs.org/api/interfaces/routeroptions)
|
||
*/
|
||
options: RouterConfigSerializable;
|
||
};
|
||
/**
|
||
* Configuration for Nuxt's TypeScript integration.
|
||
*/
|
||
typescript: {
|
||
/**
|
||
* TypeScript comes with certain checks to give you more safety and analysis of your program. Once you’ve converted your codebase to TypeScript, you can start enabling these checks for greater safety. [Read More](https://www.typescriptlang.org/docs/handbook/migrating-from-javascript.html#getting-stricter-checks)
|
||
*
|
||
*/
|
||
strict: boolean;
|
||
/**
|
||
* Which builder types to include for your project.
|
||
*
|
||
* By default Nuxt infers this based on your `builder` option (defaulting to 'vite') but you can either turn off builder environment types (with `false`) to handle this fully yourself, or opt for a 'shared' option.
|
||
* The 'shared' option is advised for module authors, who will want to support multiple possible builders.
|
||
*/
|
||
builder: "vite" | "webpack" | "rspack" | "shared" | false | undefined | null;
|
||
/**
|
||
* Modules to generate deep aliases for within `compilerOptions.paths`. This does not yet support subpaths. It may be necessary when using Nuxt within a pnpm monorepo with `shamefully-hoist=false`.
|
||
*/
|
||
hoist: Array<string>;
|
||
/**
|
||
* Include parent workspace in the Nuxt project. Mostly useful for themes and module authors.
|
||
*/
|
||
includeWorkspace: boolean;
|
||
/**
|
||
* Enable build-time type checking.
|
||
*
|
||
* If set to true, this will type check in development. You can restrict this to build-time type checking by setting it to `build`. Requires to install `typescript` and `vue-tsc` as dev dependencies.
|
||
*
|
||
* @see [Nuxt TypeScript docs](https://nuxt.com/docs/4.x/guide/concepts/typescript)
|
||
*/
|
||
typeCheck: boolean | "build";
|
||
/**
|
||
* Extend the generated tsconfig files with shared options.
|
||
*
|
||
* `compilerOptions` set here apply to all generated tsconfigs (`.nuxt/tsconfig.app.json`, `.nuxt/tsconfig.server.json`, `.nuxt/tsconfig.node.json` and `.nuxt/tsconfig.shared.json`), while `include`, `exclude` and `vueCompilerOptions` apply only to `.nuxt/tsconfig.app.json` (and the legacy `.nuxt/tsconfig.json`).
|
||
*
|
||
* Two groups of `compilerOptions` are exceptions: DOM- and Vue-specific options (such as `lib`, `jsx` and `jsxImportSource`) apply only to `.nuxt/tsconfig.app.json`, and `types`, `paths` and `noEmit` are managed by Nuxt per context, so they cannot be set globally for the `node`, `shared` and `server` tsconfigs.
|
||
*
|
||
* Use `appTsConfig`, `serverTsConfig`, `nodeTsConfig` or `sharedTsConfig` for context-specific overrides; they take precedence over this option.
|
||
*/
|
||
tsConfig: 0 extends 1 & RawVueCompilerOptions ? TSConfig : TSConfig & {
|
||
vueCompilerOptions?: RawVueCompilerOptions;
|
||
};
|
||
/**
|
||
* You can extend the generated `.nuxt/tsconfig.app.json` (and legacy `.nuxt/tsconfig.json`) using this option. Options set here take precedence over `tsConfig`.
|
||
*/
|
||
appTsConfig: 0 extends 1 & RawVueCompilerOptions ? TSConfig : TSConfig & {
|
||
vueCompilerOptions?: RawVueCompilerOptions;
|
||
};
|
||
/**
|
||
* You can extend the generated `.nuxt/tsconfig.node.json` using this option.
|
||
*/
|
||
nodeTsConfig: TSConfig;
|
||
/**
|
||
* You can extend the generated `.nuxt/tsconfig.server.json` using this option. Options set here take precedence over `tsConfig`.
|
||
*/
|
||
serverTsConfig: TSConfig;
|
||
/**
|
||
* You can extend the generated `.nuxt/tsconfig.shared.json` using this option.
|
||
*/
|
||
sharedTsConfig: TSConfig;
|
||
/**
|
||
* Generate a `*.vue` shim.
|
||
*
|
||
* We recommend instead letting the [official Vue extension](https://marketplace.visualstudio.com/items?itemName=Vue.volar) generate accurate types for your components.
|
||
* Note that you may wish to set this to `true` if you are using other libraries, such as ESLint, that are unable to understand the type of `.vue` files.
|
||
*/
|
||
shim: boolean;
|
||
};
|
||
esbuild: {
|
||
/**
|
||
* Configure shared esbuild options used within Nuxt and passed to other builders, such as Vite or Webpack.
|
||
*/
|
||
options: TransformOptions$1;
|
||
};
|
||
oxc: {
|
||
transform: {
|
||
options: TransformOptions;
|
||
};
|
||
};
|
||
/**
|
||
* Configuration that will be passed directly to Vite.
|
||
*
|
||
* @see [Vite configuration docs](https://vite.dev/config/) for more information.
|
||
* Please note that not all vite options are supported in Nuxt.
|
||
*/
|
||
vite: ViteOptions;
|
||
webpack: {
|
||
/**
|
||
* Nuxt uses `webpack-bundle-analyzer` to visualize your bundles and how to optimize them.
|
||
*
|
||
* Set to `true` to enable bundle analysis, or pass an object with options: [for webpack](https://github.com/webpack/webpack-bundle-analyzer#options-for-plugin) or [for vite](https://github.com/btd/rollup-plugin-visualizer#options).
|
||
*
|
||
* @example
|
||
* ```js
|
||
* analyze: {
|
||
* analyzerMode: 'static'
|
||
* }
|
||
* ```
|
||
*/
|
||
analyze: boolean | {
|
||
enabled?: boolean;
|
||
} & BundleAnalyzerPlugin.Options;
|
||
/**
|
||
* Enable the profiler in webpackbar.
|
||
*
|
||
* It is normally enabled by CLI argument `--profile`.
|
||
*
|
||
* @see [webpackbar](https://github.com/unjs/webpackbar#profile).
|
||
*/
|
||
profile: boolean;
|
||
/**
|
||
* Enables Common CSS Extraction.
|
||
*
|
||
* Using [mini-css-extract-plugin](https://github.com/webpack/mini-css-extract-plugin) under the hood, your CSS will be extracted into separate files, usually one per component. This allows caching your CSS and JavaScript separately.
|
||
*
|
||
* @example
|
||
* ```js
|
||
* export default {
|
||
* webpack: {
|
||
* extractCSS: true,
|
||
* // or
|
||
* extractCSS: {
|
||
* ignoreOrder: true
|
||
* }
|
||
* }
|
||
* }
|
||
* ```
|
||
*
|
||
* If you want to extract all your CSS to a single file, there is a workaround for this.
|
||
* However, note that it is not recommended to extract everything into a single file.
|
||
* Extracting into multiple CSS files is better for caching and preload isolation. It
|
||
* can also improve page performance by downloading and resolving only those resources
|
||
* that are needed.
|
||
*
|
||
* @example
|
||
* ```js
|
||
* export default {
|
||
* webpack: {
|
||
* extractCSS: true,
|
||
* optimization: {
|
||
* splitChunks: {
|
||
* cacheGroups: {
|
||
* styles: {
|
||
* name: 'styles',
|
||
* test: /\.(css|vue)$/,
|
||
* chunks: 'all',
|
||
* enforce: true
|
||
* }
|
||
* }
|
||
* }
|
||
* }
|
||
* }
|
||
* }
|
||
* ```
|
||
*/
|
||
extractCSS: boolean | PluginOptions;
|
||
/**
|
||
* Enables CSS source map support (defaults to `true` in development).
|
||
*/
|
||
cssSourceMap: boolean;
|
||
/**
|
||
* The polyfill library to load to provide URL and URLSearchParams.
|
||
*
|
||
* Defaults to `'url'` ([see package](https://www.npmjs.com/package/url)).
|
||
*/
|
||
serverURLPolyfill: string;
|
||
/**
|
||
* Customize bundle filenames.
|
||
*
|
||
* To understand a bit more about the use of manifests, take a look at [webpack documentation](https://webpack.js.org/guides/code-splitting/).
|
||
*
|
||
* @note Be careful when using non-hashed based filenames in production
|
||
* as most browsers will cache the asset and not detect the changes on first load.
|
||
*
|
||
* This example changes fancy chunk names to numerical ids:
|
||
*
|
||
* @example
|
||
* ```js
|
||
* filenames: {
|
||
* chunk: ({ isDev }) => (isDev ? '[name].js' : '[id].[contenthash].js')
|
||
* }
|
||
* ```
|
||
*/
|
||
filenames: Record<string, string | ((ctx: {
|
||
nuxt: Nuxt;
|
||
options: NuxtOptions;
|
||
name: string;
|
||
isDev: boolean;
|
||
isServer: boolean;
|
||
isClient: boolean;
|
||
alias: {
|
||
[index: string]: string | false | string[];
|
||
};
|
||
transpile: RegExp[];
|
||
}) => string)>;
|
||
/**
|
||
* Customize the options of Nuxt's integrated webpack loaders.
|
||
*/
|
||
loaders: {
|
||
/**
|
||
* @see [esbuild loader](https://github.com/privatenumber/esbuild-loader)
|
||
*/
|
||
esbuild: Omit<LoaderOptions, "loader">;
|
||
/**
|
||
* @see [`file-loader` Options](https://github.com/webpack/file-loader#options)
|
||
*/
|
||
file: {
|
||
esModule: boolean;
|
||
limit: number;
|
||
};
|
||
/**
|
||
* @see [`file-loader` Options](https://github.com/webpack/file-loader#options)
|
||
*/
|
||
fontUrl: {
|
||
esModule: boolean;
|
||
limit: number;
|
||
};
|
||
/**
|
||
* @see [`file-loader` Options](https://github.com/webpack/file-loader#options)
|
||
*/
|
||
imgUrl: {
|
||
esModule: boolean;
|
||
limit: number;
|
||
};
|
||
/**
|
||
* @see [`pug` options](https://pugjs.org/api/reference.html#options)
|
||
*/
|
||
pugPlain: Options$4;
|
||
/**
|
||
* See [vue-loader](https://github.com/vuejs/vue-loader) for available options.
|
||
*/
|
||
vue: Partial<VueLoaderOptions>;
|
||
/**
|
||
* See [css-loader](https://github.com/webpack/css-loader) for available options.
|
||
*/
|
||
css: {
|
||
importLoaders: number;
|
||
url: boolean | {
|
||
filter: (url: string, resourcePath: string) => boolean;
|
||
};
|
||
esModule: boolean;
|
||
};
|
||
/**
|
||
* See [css-loader](https://github.com/webpack/css-loader) for available options.
|
||
*/
|
||
cssModules: {
|
||
importLoaders: number;
|
||
url: boolean | {
|
||
filter: (url: string, resourcePath: string) => boolean;
|
||
};
|
||
esModule: boolean;
|
||
modules: {
|
||
localIdentName: string;
|
||
};
|
||
};
|
||
/**
|
||
* @see [`less-loader` Options](https://github.com/webpack/less-loader#options)
|
||
*/
|
||
less: any;
|
||
/**
|
||
* @see [`sass-loader` Options](https://github.com/webpack/sass-loader#options)
|
||
*/
|
||
sass: {
|
||
sassOptions: {
|
||
indentedSyntax: boolean;
|
||
};
|
||
};
|
||
/**
|
||
* @see [`sass-loader` Options](https://github.com/webpack/sass-loader#options)
|
||
*/
|
||
scss: any;
|
||
/**
|
||
* @see [`stylus-loader` Options](https://github.com/webpack/stylus-loader#options)
|
||
*/
|
||
stylus: any;
|
||
vueStyle: any;
|
||
};
|
||
/**
|
||
* Add webpack plugins.
|
||
*
|
||
* @example
|
||
* ```js
|
||
* import webpack from 'webpack'
|
||
* import { version } from './package.json.ts'
|
||
* // ...
|
||
* plugins: [
|
||
* new webpack.DefinePlugin({
|
||
* 'process.VERSION': version
|
||
* })
|
||
* ]
|
||
* ```
|
||
*/
|
||
plugins: Array<any>;
|
||
/**
|
||
* Hard-replaces `typeof process`, `typeof window` and `typeof document` to tree-shake bundle.
|
||
*/
|
||
aggressiveCodeRemoval: boolean;
|
||
/**
|
||
* OptimizeCSSAssets plugin options.
|
||
*
|
||
* Defaults to true when `extractCSS` is enabled.
|
||
*
|
||
* @see [css-minimizer-webpack-plugin documentation](https://github.com/webpack/css-minimizer-webpack-plugin).
|
||
*/
|
||
optimizeCSS: false | BasePluginOptions & DefinedDefaultMinimizerAndOptions<{}>;
|
||
/**
|
||
* Configure [webpack optimization](https://webpack.js.org/configuration/optimization/).
|
||
*/
|
||
optimization: false | Configuration["optimization"];
|
||
/**
|
||
* Customize PostCSS Loader. same options as [`postcss-loader` options](https://github.com/webpack/postcss-loader#options)
|
||
*/
|
||
postcss: {
|
||
execute?: boolean;
|
||
postcssOptions: ProcessOptions & {
|
||
plugins: Record<string, unknown> & {
|
||
autoprefixer?: Options$2;
|
||
cssnano?: Options$3;
|
||
};
|
||
};
|
||
sourceMap?: boolean;
|
||
implementation?: any;
|
||
};
|
||
/**
|
||
* See [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware) for available options.
|
||
*/
|
||
devMiddleware: Options$5<IncomingMessage, ServerResponse>;
|
||
/**
|
||
* See [webpack-hot-middleware](https://github.com/webpack/webpack-hot-middleware) for available options.
|
||
*/
|
||
hotMiddleware: MiddlewareOptions & {
|
||
client?: ClientOptions;
|
||
};
|
||
/**
|
||
* Set to `false` to stop printing client build errors to the terminal during development.
|
||
*/
|
||
friendlyErrors: boolean;
|
||
/**
|
||
* Filters to hide build warnings.
|
||
*/
|
||
warningIgnoreFilters: Array<(warn: WebpackError | Error) => boolean>;
|
||
/**
|
||
* Configure [webpack experiments](https://webpack.js.org/configuration/experiments/)
|
||
*/
|
||
experiments: false | Configuration["experiments"];
|
||
};
|
||
}
|
||
/**
|
||
* Metadata describing a config layer, taken from the `$meta` key of its `nuxt.config`.
|
||
*
|
||
* A layer's `name` is used to register the `#layers/<name>` alias.
|
||
*/
|
||
interface NuxtConfigLayerMeta {
|
||
name?: string;
|
||
[key: string]: any;
|
||
}
|
||
/**
|
||
* Options for a single entry in `extends`, supplied as the second element of a tuple:
|
||
*
|
||
* ```ts
|
||
* export default defineNuxtConfig({
|
||
* extends: [['github:my-org/my-theme', { auth: process.env.GITHUB_TOKEN }]],
|
||
* })
|
||
* ```
|
||
*/
|
||
interface NuxtLayerSourceOptions {
|
||
/** Metadata to attach to the resolved layer, merged over the layer's own `$meta`. */
|
||
meta?: NuxtConfigLayerMeta;
|
||
/** Configuration applied on top of the layer's own configuration. */
|
||
overrides?: NuxtConfig;
|
||
/** Install the layer's dependencies after cloning a remote source. */
|
||
install?: boolean;
|
||
/** Token used to clone a private remote source. */
|
||
auth?: string;
|
||
[key: string]: any;
|
||
}
|
||
/** Options controlling how `.env` files are loaded into `process.env` before config resolution. */
|
||
interface NuxtDotenvOptions {
|
||
/** Directory to resolve `.env` files from. Defaults to the config loading `cwd`. */
|
||
cwd?: string;
|
||
/**
|
||
* File or files to read environment variables from, relative to `cwd`.
|
||
*
|
||
* With an array, later entries override earlier ones.
|
||
* @default '.env'
|
||
*/
|
||
fileName?: string | string[];
|
||
/**
|
||
* Interpolate `${VAR}` references within `.env` values.
|
||
* @default true
|
||
*/
|
||
interpolate?: boolean;
|
||
/** Object to read from and write resolved variables into. Defaults to `process.env`. */
|
||
env?: NodeJS.ProcessEnv;
|
||
/**
|
||
* Resolve `_FILE`-suffixed variables by reading the file they point at and assigning its
|
||
* trimmed contents to the base key, for container secrets mounted as files.
|
||
* @default false
|
||
*/
|
||
expandFileReferences?: boolean;
|
||
}
|
||
/**
|
||
* A single resolved configuration layer, as found in `nuxt.options._layers`.
|
||
*
|
||
* Layers are ordered highest priority first, with the root project itself as the first entry.
|
||
*/
|
||
interface NuxtConfigLayer {
|
||
/** The layer's own configuration, with its directory options resolved to absolute paths. */
|
||
config: NuxtConfig & {
|
||
srcDir: ConfigSchema["srcDir"];
|
||
rootDir: ConfigSchema["rootDir"];
|
||
};
|
||
/** Absolute path of the directory the layer was loaded from. */
|
||
cwd: string;
|
||
/** Absolute path of the layer's `nuxt.config` file. */
|
||
configFile: string;
|
||
/** The `extends` entry this layer was resolved from, if it came from one. */
|
||
source?: string;
|
||
/** Options supplied alongside `source` in `extends`. */
|
||
sourceOptions?: NuxtLayerSourceOptions;
|
||
/** The layer's `$meta`. */
|
||
meta?: NuxtConfigLayerMeta;
|
||
}
|
||
/**
|
||
* Bundler types re-exported for the utilities that extend a bundler's own configuration.
|
||
*
|
||
* Authoring a Vite or webpack plugin is not possible without the bundler's types, so these are a
|
||
* deliberate exception to Nuxt owning its public types: `@nuxt/kit` takes them from here rather
|
||
* than importing the bundlers itself.
|
||
*/
|
||
type VitePlugin = Plugin;
|
||
type WebpackConfig = Configuration;
|
||
type WebpackPluginInstance$1 = WebpackPluginInstance;
|
||
type DeepPartial<T> = T extends Function ? T : T extends Record<string, any> ? { [P in keyof T]?: DeepPartial<T[P]>; } : T;
|
||
type UpperSnakeCase<S extends string> = Uppercase<SnakeCase<S>>;
|
||
declare const message: symbol;
|
||
type RuntimeValue<T, B extends string> = T & {
|
||
[message]?: B;
|
||
} | T;
|
||
type Overrideable<T extends Record<string, any>, Path extends string = ""> = { [K in keyof T]?: K extends string ? unknown extends T[K] ? unknown : T[K] extends Record<string, unknown> ? RuntimeValue<Overrideable<T[K], `${Path}_${UpperSnakeCase<K>}`>, `You can override this value at runtime with NUXT${Path}_${UpperSnakeCase<K>}`> : RuntimeValue<T[K], `You can override this value at runtime with NUXT${Path}_${UpperSnakeCase<K>}`> : K extends number ? T[K] : never; };
|
||
type RuntimeConfigNamespace = Record<string, unknown>;
|
||
interface PublicRuntimeConfig extends RuntimeConfigNamespace {}
|
||
/** Runtime configuration of the app itself, set at build time from `app` and `buildId`. */
|
||
interface RuntimeConfigApp extends RuntimeConfigNamespace {
|
||
/** The base path the app is served from. */
|
||
baseURL: string;
|
||
/** The folder name for the built site assets, relative to `baseURL` (or `cdnURL` if set). */
|
||
buildAssetsDir: string;
|
||
/** An absolute URL the public folder is served from (production-only). */
|
||
cdnURL: string;
|
||
/** Identifier of the current build, regenerated on every build. */
|
||
buildId: string;
|
||
}
|
||
interface RuntimeConfig extends RuntimeConfigNamespace {
|
||
/** The application's root secret, overridable at runtime with `NUXT_APP_SECRET`. */
|
||
appSecret: string;
|
||
public: PublicRuntimeConfig;
|
||
app: RuntimeConfigApp;
|
||
}
|
||
/**
|
||
* User configuration in `nuxt.config` file
|
||
*/
|
||
interface NuxtConfig extends DeepPartial<Omit<ConfigSchema, "components" | "vue" | "vite" | "runtimeConfig" | "webpack" | "nitro">> {
|
||
components?: ConfigSchema["components"];
|
||
vue?: Omit<DeepPartial<ConfigSchema["vue"]>, "config"> & {
|
||
config?: Partial<Filter<AppConfig, string | boolean>>;
|
||
};
|
||
vite?: ConfigSchema["vite"];
|
||
nitro?: ConfigSchema["nitro"];
|
||
runtimeConfig?: Overrideable<RuntimeConfig>;
|
||
webpack?: DeepPartial<ConfigSchema["webpack"]> & {
|
||
$client?: DeepPartial<ConfigSchema["webpack"]>;
|
||
$server?: DeepPartial<ConfigSchema["webpack"]>;
|
||
};
|
||
/**
|
||
* Experimental custom config schema
|
||
* @see [Nuxt Issue #15592](https://github.com/nuxt/nuxt/issues/15592)
|
||
*/
|
||
$schema?: SchemaDefinition;
|
||
}
|
||
/**
|
||
* Environment- and metadata-aware wrapper around a user configuration object, allowing
|
||
* `$production`/`$development`/`$test`/`$env` overrides and a `$meta` layer descriptor
|
||
* alongside the configuration itself.
|
||
*/
|
||
type NuxtConfigInput<Config extends Record<string, any> = NuxtConfig> = Config & {
|
||
$test?: Config;
|
||
$development?: Config;
|
||
$production?: Config;
|
||
$env?: Record<string, Config>;
|
||
$meta?: NuxtConfigLayerMeta;
|
||
};
|
||
interface DefineNuxtConfig<Config extends Record<string, any> = NuxtConfig> {
|
||
(input: NuxtConfigInput<Config>): NuxtConfigInput<Config>;
|
||
}
|
||
interface NuxtBuilder {
|
||
bundle: (nuxt: Nuxt) => Promise<void>;
|
||
/**
|
||
* Optional. If provided and the user opts in via `experimental.watcher: 'builder'`,
|
||
* Nuxt will call this instead of starting its own file watcher in dev mode,
|
||
* allowing the builder to reuse its own watcher.
|
||
*
|
||
* The builder is expected to register its own `nuxt.hook('close', ...)` to
|
||
* clean up any resources it allocates.
|
||
*/
|
||
setupWatcher?: (nuxt: Nuxt) => Promise<void> | void;
|
||
}
|
||
interface NuxtOptions extends Omit<ConfigSchema, "vue" | "sourcemap" | "debug" | "builder" | "postcss" | "webpack"> {
|
||
vue: Omit<ConfigSchema["vue"], "config"> & {
|
||
config?: Partial<Filter<AppConfig, string | boolean>>;
|
||
};
|
||
sourcemap: Required<Exclude<ConfigSchema["sourcemap"], boolean>>;
|
||
debug: Required<Exclude<ConfigSchema["debug"], true>>;
|
||
builder: "@nuxt/vite-builder" | "@nuxt/webpack-builder" | "@nuxt/rspack-builder" | NuxtBuilder;
|
||
postcss: Omit<ConfigSchema["postcss"], "order"> & {
|
||
order: Exclude<ConfigSchema["postcss"]["order"], string>;
|
||
};
|
||
webpack: ConfigSchema["webpack"] & {
|
||
$client: ConfigSchema["webpack"];
|
||
$server: ConfigSchema["webpack"];
|
||
};
|
||
_layers: readonly NuxtConfigLayer[];
|
||
$schema: SchemaDefinition;
|
||
}
|
||
interface ViteConfig extends Omit<UserConfig, "publicDir"> {
|
||
/** The path to the entrypoint for the Vite build. */
|
||
entry?: string;
|
||
/**
|
||
* Options passed to @vitejs/plugin-vue.
|
||
* @see [@vitejs/plugin-vue](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue)
|
||
*/
|
||
vue?: Options;
|
||
/**
|
||
* Options passed to @vitejs/plugin-vue-jsx.
|
||
* @see [@vitejs/plugin-vue-jsx.](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx)
|
||
*/
|
||
vueJsx?: Options$1;
|
||
/**
|
||
* Warmup vite entrypoint caches on dev startup.
|
||
*
|
||
* In dev mode Nuxt crawls the client entry's import graph once Nitro has built, transforming
|
||
* modules the browser is about to request. Set to `false` to skip this speculative work, which
|
||
* also disables Vite's own entry warmup.
|
||
* @default true
|
||
*/
|
||
warmupEntry?: boolean;
|
||
/**
|
||
* Use environment variables or top level `server` options to configure Nuxt server.
|
||
*/
|
||
server?: Omit<ServerOptions, "port" | "host">;
|
||
/**
|
||
* Directly configuring the `vite.publicDir` option is not supported. Instead, set `dir.public`.
|
||
*
|
||
* You can read more in <https://nuxt.com/docs/4.x/api/nuxt-config#public>.
|
||
* @deprecated
|
||
*/
|
||
publicDir?: never;
|
||
}
|
||
interface ViteOptions extends ViteConfig {}
|
||
interface CustomAppConfig {
|
||
[key: string]: unknown;
|
||
}
|
||
/**
|
||
* User-authored `app.config.ts` input.
|
||
*/
|
||
interface AppConfigInput {
|
||
[key: string]: unknown;
|
||
/** @deprecated reserved */
|
||
private?: never;
|
||
/** @deprecated reserved */
|
||
nuxt?: never;
|
||
/** @deprecated reserved */
|
||
nitro?: never;
|
||
/** @deprecated reserved */
|
||
server?: never;
|
||
}
|
||
type Serializable<T> = T extends Function ? never : T extends Promise<infer U> ? Serializable<U> : T extends string & {} ? T : T extends Record<string, any> ? { [K in keyof T]: Serializable<T[K]>; } : T;
|
||
type ValueOf<T> = T[keyof T];
|
||
type Filter<T extends Record<string, any>, V> = Pick<T, ValueOf<{ [K in keyof T]: NonNullable<T[K]> extends V ? K : never; }>>;
|
||
interface NuxtAppConfig {
|
||
head: Serializable<AppHeadMetaObject>;
|
||
layoutTransition: boolean | Serializable<TransitionProps>;
|
||
pageTransition: boolean | Serializable<TransitionProps>;
|
||
viewTransition?: ViewTransitionOptions["enabled"] | ViewTransitionOptions;
|
||
keepalive: boolean | Serializable<KeepAliveProps>;
|
||
}
|
||
interface AppConfig$1 {
|
||
[key: string]: unknown;
|
||
}
|
||
/** App config available in shared and server contexts, excluding user `app.config` files. */
|
||
interface SharedAppConfig {
|
||
[key: string]: unknown;
|
||
}
|
||
interface ViewTransitionOptions {
|
||
enabled: boolean | "always";
|
||
types?: string[];
|
||
}
|
||
type ViewTransitionTypesFn = (to: RouteLocationNormalizedGeneric, from: RouteLocationNormalizedGeneric) => string[];
|
||
interface ViewTransitionPageOptions {
|
||
enabled?: boolean | "always";
|
||
types?: string[] | ViewTransitionTypesFn;
|
||
toTypes?: string[] | ViewTransitionTypesFn;
|
||
fromTypes?: string[] | ViewTransitionTypesFn;
|
||
}
|
||
/**
|
||
* Extension point through which the configured `server.builder` contributes the type of the
|
||
* request event its runtime hands to the app layer.
|
||
*
|
||
* `@nuxt/nitro-server` declares `event` here as h3's `H3Event` and `routeRules` as its own
|
||
* `NitroRouteRules`, and Nuxt references its
|
||
* declarations from the generated `.nuxt` types. Declaring the event where it is constructed
|
||
* keeps the resolved shape accurate without the app layer depending on a server runtime.
|
||
*/
|
||
interface ServerTypes {}
|
||
/** @internal */
|
||
type ResolveServerEventHandler<T> = T extends {
|
||
eventHandler: infer H;
|
||
} ? H : (...args: any[]) => unknown;
|
||
/**
|
||
* A handler the server runtime can mount, which is why the runtime declares it: it is the
|
||
* shape a bundler's dev middleware is handed over in through `server:devHandler`.
|
||
*/
|
||
type ServerEventHandler = ResolveServerEventHandler<ServerTypes>;
|
||
/**
|
||
* Extension point through which the configured `server.builder` contributes the response types
|
||
* of the routes its runtime serves.
|
||
*
|
||
* Keys are route patterns (as written by the server runtime, so they may contain `:param` and
|
||
* `**` segments) and values map a lowercased HTTP method - or `default`, for handlers that
|
||
* answer every method - to the type that route resolves to.
|
||
*
|
||
* `@nuxt/nitro-server` declares the routes Nitro has scanned here, and Nuxt references its
|
||
* declarations from the generated `.nuxt` types. Declaring routes where they are scanned keeps
|
||
* `$fetch` and `useFetch` typing accurate without the app layer depending on a particular
|
||
* server runtime.
|
||
*
|
||
* @example
|
||
* ```ts
|
||
* declare module '@nuxt/schema' {
|
||
* interface ServerRoutes {
|
||
* '/api/hello': { get: { message: string } }
|
||
* }
|
||
* }
|
||
* ```
|
||
*/
|
||
interface ServerRoutes {}
|
||
/**
|
||
* One part of a route pattern, as matched by the server's router.
|
||
*
|
||
* A static segment may span several path segments (`/api/users`), which keeps the generated type
|
||
* tree shallow. Parameters are described by how much they match rather than by name, because a
|
||
* name cannot narrow a response type.
|
||
*/
|
||
type ServerRouteSegment = {
|
||
type: "static";
|
||
value: string;
|
||
} | {
|
||
type: "dynamic";
|
||
} | {
|
||
type: "wildcard";
|
||
};
|
||
/**
|
||
* Types the configured `server.builder` contributes for reading a handler's validated request
|
||
* shapes, named as `Type<typeof handler>` in generated declarations.
|
||
*
|
||
* Reading these means naming the server runtime's own event type, so the builder supplies them
|
||
* rather than the app layer deriving them. A builder that omits a key contributes no typing for
|
||
* it, leaving that part of the request as permissive as it was.
|
||
*/
|
||
interface ServerRequestTypes {
|
||
/** Module the types are imported from, resolvable from the project. */
|
||
module: string;
|
||
/** Name of the type resolving a handler's validated body. */
|
||
body?: string;
|
||
/** Name of the type resolving a handler's validated query. */
|
||
query?: string;
|
||
/** Name of the type resolving a handler's validated headers. */
|
||
headers?: string;
|
||
}
|
||
/**
|
||
* A route handler the configured `server.builder` will serve.
|
||
*
|
||
* Contributed by the builder through the `server:routes` hook, which is how Nuxt learns about
|
||
* handlers it did not register itself: file-based handlers are discovered by the builder's own
|
||
* scan, so it is the only party that knows the full set.
|
||
*/
|
||
interface ServerRouteHandler {
|
||
/**
|
||
* The pattern split into the segments the builder's router matches on.
|
||
*
|
||
* The builder derives these from its own router so that the types Nuxt generates and the
|
||
* routing that serves the request cannot disagree. Route syntax (`:param`, `**`, optional
|
||
* parameters and constraints) is therefore the builder's to interpret, not Nuxt's.
|
||
*/
|
||
segments: ServerRouteSegment[];
|
||
/** The route as originally written, for diagnostics. */
|
||
route?: string;
|
||
/** Lowercased HTTP method the handler answers, or `undefined` when it answers every method. */
|
||
method?: string;
|
||
/** Absolute path to the file whose default export implements the handler. */
|
||
handler: string;
|
||
/** Whether the handler runs for every request instead of serving a route of its own. */
|
||
middleware?: boolean;
|
||
}
|
||
/**
|
||
* Nuxt-owned per-request state, carried on the request event's context under `nuxt`.
|
||
*
|
||
* This is the channel the app layer and the SSR renderer use to communicate with the
|
||
* configured `server.builder`, which is free to translate it into whatever its own runtime
|
||
* understands (Nitro turns {@link NuxtRequestContext.prerenderRoutes} into the response header
|
||
* its crawler reads).
|
||
*/
|
||
interface NuxtRequestContext {
|
||
"appConfig"?: SharedAppConfig;
|
||
"noSSR"?: boolean;
|
||
/**
|
||
* Routes to additionally prerender, as raw paths, collected from `prerenderRoutes()` and from
|
||
* the renderer's own hints while a route is prerendered.
|
||
*/
|
||
"prerenderRoutes"?: string[];
|
||
/** @internal */
|
||
"~internal"?: boolean;
|
||
/** @internal */
|
||
"~rendering-error"?: boolean;
|
||
/**
|
||
* Dev-only: CSS module URLs the builder has loaded for this request, provided
|
||
* by a dev integration so the SSR renderer can emit the right stylesheet
|
||
* links / inline styles. @internal
|
||
*/
|
||
"~devClientCss"?: string[];
|
||
/** @internal */
|
||
"~error-cause"?: unknown;
|
||
}
|
||
/** The context of a {@link RequestEvent}, which carries Nuxt's own per-request state. */
|
||
interface RequestEventContext extends Record<string, unknown> {
|
||
nuxt?: NuxtRequestContext;
|
||
/**
|
||
* The dynamic segments the server builder matched for the request. Read them with
|
||
* `getRouterParams()`, which returns them percent-encoded as they appear in the URL.
|
||
*/
|
||
params?: Record<string, string | undefined>;
|
||
}
|
||
/**
|
||
* The web-standard part of a request event, which every server runtime provides. Portable
|
||
* server code is written against this, and the event resolves to it when no server builder
|
||
* has contributed one.
|
||
*/
|
||
interface RequestEvent {
|
||
readonly req: Request;
|
||
url: URL;
|
||
readonly res: {
|
||
status?: number;
|
||
statusText?: string;
|
||
readonly headers: Headers;
|
||
};
|
||
readonly context: RequestEventContext;
|
||
}
|
||
/**
|
||
* Server runtime hooks declared by modules. Augment it to declare a hook.
|
||
*
|
||
* @example
|
||
* ```ts
|
||
* declare module 'nuxt/schema' {
|
||
* interface NuxtServerHooks {
|
||
* 'my-module:request': (payload: { url: string }, event: RequestEvent) => void | Promise<void>
|
||
* }
|
||
* }
|
||
* ```
|
||
*
|
||
* @since 4.6.0
|
||
*/
|
||
interface NuxtServerHooks {}
|
||
/**
|
||
* Resolves the event type contributed to a {@link ServerTypes} registry, or
|
||
* {@link RequestEvent} when the registry does not declare one. Exported for type tests;
|
||
* not part of the public API.
|
||
*
|
||
* @internal
|
||
*/
|
||
type ResolveRequestEvent<T> = T extends {
|
||
event: infer E;
|
||
} ? E : RequestEvent;
|
||
/**
|
||
* The request event in the shape the configured `server.builder` provides (an `h3` v1
|
||
* `H3Event` under `@nuxt/nitro-server`), or {@link RequestEvent} when none has contributed
|
||
* one.
|
||
*
|
||
* Returned by server-side composables such as `useRequestEvent()`.
|
||
*/
|
||
type NuxtRequestEvent = ResolveRequestEvent<ServerTypes>;
|
||
/**
|
||
* The route rules the app layer reads, as compiled into the route-rules matcher: keys the
|
||
* server builder resolves for itself (headers, caching, proxying, and so on) are not part of
|
||
* it, and rules the app layer normalises are described in their normalised form.
|
||
*
|
||
* A server builder contributes its own rules through the `routeRules` key of a
|
||
* {@link ServerTypes} registry, and they are resolved into {@link AppRouteRules}.
|
||
*/
|
||
interface AppRouteRulesBase {
|
||
/** Whether the matched route is prerendered. */
|
||
prerender?: boolean;
|
||
/** Path the matched route redirects to. */
|
||
redirect?: string;
|
||
/** Whether a payload is cached for the matched route. */
|
||
payload?: boolean;
|
||
/** Named app middleware to run (`true`) or skip (`false`) for the matched route. */
|
||
appMiddleware?: Record<string, boolean>;
|
||
/** Whether the matched route is rendered on the server. */
|
||
ssr?: boolean;
|
||
/** Whether the matched route is rendered without any scripts. */
|
||
noScripts?: boolean;
|
||
}
|
||
/**
|
||
* Extension point for app-facing route rules that are not known statically, such as
|
||
* `appLayout`, whose values Nuxt generates from the layouts it has scanned.
|
||
*
|
||
* Rules declared here take precedence over those the server builder contributes, so they
|
||
* describe the value the app layer reads rather than the value the server was configured
|
||
* with.
|
||
*/
|
||
interface AppRouteRulesExtensions {}
|
||
/**
|
||
* Resolves the route rules contributed to a {@link ServerTypes} registry against the
|
||
* app-facing rules, which win where both describe a rule. Exported for type tests; not part
|
||
* of the public API.
|
||
*
|
||
* @internal
|
||
*/
|
||
type ResolveAppRouteRules<T> = AppRouteRulesBase & AppRouteRulesExtensions & (T extends {
|
||
routeRules: infer R;
|
||
} ? Omit<R, keyof AppRouteRulesBase | keyof AppRouteRulesExtensions> : unknown);
|
||
/**
|
||
* The route rules matched for a route in the app, combining the rules the app layer itself
|
||
* reads with those declared by the configured `server.builder`.
|
||
*/
|
||
type AppRouteRules = ResolveAppRouteRules<ServerTypes>;
|
||
/**
|
||
* Extension point through which the configured `server.builder` contributes the types of the
|
||
* server it builds: the instance it constructs, and the configuration it accepts.
|
||
*
|
||
* Nitro is not a dependency of `@nuxt/schema` and which major is installed is the builder's
|
||
* decision, so these are declared where they are built rather than imported here.
|
||
*/
|
||
interface NitroTypes {}
|
||
/** Auto-imports injected into the server program, as written by `addServerImports()`. */
|
||
interface ServerImportsOptions {
|
||
autoImport?: boolean;
|
||
dirs?: string[];
|
||
imports?: NuxtImport[];
|
||
presets?: Array<{
|
||
from: string;
|
||
imports: Array<string | {
|
||
name: string;
|
||
as?: string;
|
||
}>;
|
||
typeFrom?: string;
|
||
}>;
|
||
exclude?: Array<string | RegExp>;
|
||
}
|
||
/** A handler entry in a server builder's own configuration, when it contributes no types. */
|
||
interface ServerHandlerFallback {
|
||
handler: string;
|
||
route?: string;
|
||
method?: string;
|
||
middleware?: boolean;
|
||
lazy?: boolean;
|
||
}
|
||
/** A development-only handler entry in a server builder's own configuration. */
|
||
interface DevServerHandlerFallback {
|
||
route?: string;
|
||
handler: unknown;
|
||
}
|
||
/**
|
||
* The server API a piece of server code is written against.
|
||
*
|
||
* - `nitro2`: nitropack v2 and h3 v1 (`h3`, `nitropack/runtime`, `#imports`). Runs on a
|
||
* Nitro v3 host through the compatibility layer.
|
||
* - `nitro3`: Nitro v3 and h3 v2 (`nitro`, `nitro/h3`). Pinned to the Nitro server builder.
|
||
* - `nuxt`: only `nuxt/server`. Runs under any server builder.
|
||
*
|
||
* A closed set today; a server builder may contribute further values later.
|
||
*/
|
||
type ServerApi = "nitro2" | "nitro3" | "nuxt";
|
||
/**
|
||
* One implementation, or one per server API for code mid-migration. Only the one the host
|
||
* prefers is registered.
|
||
*/
|
||
type ServerApiVariants<T, Api extends ServerApi = ServerApi> = T | Partial<Record<Api, T>>;
|
||
type ServerHandlerMethod = "GET" | "HEAD" | "PATCH" | "POST" | "PUT" | "DELETE" | "CONNECT" | "OPTIONS" | "TRACE" | "QUERY";
|
||
/** Environments a handler is bundled for. */
|
||
type ServerHandlerEnv = "dev" | "prod" | "prerender" | (string & {});
|
||
interface ServerRouteMeta {
|
||
openAPI?: Record<string, any>;
|
||
}
|
||
/**
|
||
* What a route handler registration says about itself, apart from where its implementation
|
||
* lives. The configured `server.builder` normalises it into whatever its own runtime
|
||
* accepts; reach for `nuxt.options.nitro.handlers` to write an entry typed by Nitro itself.
|
||
*/
|
||
interface ServerHandlerBase {
|
||
/**
|
||
* HTTP pathname pattern to match. A handler registered without one is middleware that
|
||
* runs on every route.
|
||
*
|
||
* @example "/test", "/api/:id", "/blog/**"
|
||
*/
|
||
route?: string;
|
||
/**
|
||
* HTTP method to match. `QUERY` requires a server runtime that implements it, and the
|
||
* registration is skipped on one that does not.
|
||
*/
|
||
method?: ServerHandlerMethod | Lowercase<ServerHandlerMethod>;
|
||
/** Run the handler as middleware, before other route handlers. */
|
||
middleware?: boolean;
|
||
/** Import the handler lazily, on first use. */
|
||
lazy?: boolean;
|
||
/** Route metadata (e.g. OpenAPI operation info). */
|
||
meta?: ServerRouteMeta;
|
||
/** Environments to include and bundle this handler for. */
|
||
env?: ServerHandlerEnv | ServerHandlerEnv[];
|
||
/**
|
||
* Handler module format. Requires a server runtime that converts node handlers, and is
|
||
* dropped on one that does not.
|
||
*/
|
||
format?: "web" | "node";
|
||
}
|
||
/** A route handler registration, as written into `serverHandlers`. */
|
||
interface ServerHandler extends ServerHandlerBase {
|
||
/** Path to the handler. */
|
||
handler: string;
|
||
}
|
||
/**
|
||
* A route handler registration as `addServerHandler()` accepts it. Only the variant the
|
||
* host runs reaches `serverHandlers`.
|
||
*/
|
||
interface ServerHandlerInput extends ServerHandlerBase {
|
||
/** Path to the handler, or one path per server API. */
|
||
handler: ServerApiVariants<string>;
|
||
}
|
||
/** A development-only handler: a function taking the request event, or a fetchable object. */
|
||
type DevServerHandlerFunction = ((...args: any[]) => any) | {
|
||
fetch: (...args: any[]) => any;
|
||
} | Record<string, any>;
|
||
/** What a development-only handler registration says about itself. */
|
||
interface DevServerHandlerBase {
|
||
/** HTTP pathname pattern to match. */
|
||
route?: string;
|
||
/** HTTP method to match. */
|
||
method?: ServerHandlerMethod | Lowercase<ServerHandlerMethod>;
|
||
/** Run the handler as middleware, before other route handlers. */
|
||
middleware?: boolean;
|
||
/** Route metadata (e.g. OpenAPI operation info). */
|
||
meta?: ServerRouteMeta;
|
||
}
|
||
/** A development-only route handler registration, as written into `devServerHandlers`. */
|
||
interface DevServerHandler extends DevServerHandlerBase {
|
||
handler: DevServerHandlerFunction;
|
||
}
|
||
/** A development-only registration as `addDevServerHandler()` accepts it. */
|
||
interface DevServerHandlerInput extends DevServerHandlerBase {
|
||
/** The handler, or one per server API. */
|
||
handler: DevServerHandlerFunction | {
|
||
nuxt?: (event: RequestEvent) => unknown;
|
||
nitro2?: DevServerHandlerFunction;
|
||
nitro3?: DevServerHandlerFunction;
|
||
};
|
||
}
|
||
/**
|
||
* A plugin as `addNitroPlugin()` accepts it. There is no portable variant: `nuxt/server`
|
||
* has no plugin surface, so a startup plugin is written against a nitro major.
|
||
*/
|
||
type ServerPluginInput = ServerApiVariants<string, Exclude<ServerApi, "nuxt">>;
|
||
/** A resolved server plugin registration, as written into `_serverPlugins`. */
|
||
interface ServerPlugin {
|
||
/** Path to the plugin the host runs. */
|
||
plugin: string;
|
||
/** The server API it was registered for, when the module named one. */
|
||
compatibility?: ServerApi;
|
||
/** Paths of the variants the host does not run. */
|
||
unused?: string[];
|
||
}
|
||
interface RouteRuleConfigFallback extends RouteRuleConfigExtensions {
|
||
prerender?: boolean;
|
||
ssr?: boolean;
|
||
noScripts?: boolean;
|
||
payload?: boolean;
|
||
redirect?: string | {
|
||
to: string;
|
||
status?: number;
|
||
} | false;
|
||
isr?: number | boolean | Record<string, any>;
|
||
cache?: false | Record<string, any>;
|
||
}
|
||
/** @internal */
|
||
type ResolveRouteRuleConfig<T> = T extends {
|
||
routeRuleConfig: infer R;
|
||
} ? R : RouteRuleConfigFallback;
|
||
/**
|
||
* Extension point for rules that may be configured for a route pattern but are not known
|
||
* statically, such as `appLayout` and `appMiddleware`, whose values Nuxt generates from the
|
||
* layouts and middleware it has scanned.
|
||
*
|
||
* A server builder that resolves rules with its own types bridges these into them, so that a
|
||
* rule is configurable whichever type describes the configuration.
|
||
*/
|
||
interface RouteRuleConfigExtensions {}
|
||
/**
|
||
* The rules that may be configured for a route pattern. `AppRouteRules` describes the same
|
||
* rules as the app layer reads them, once matched and normalised.
|
||
*/
|
||
type RouteRuleConfig = ResolveRouteRuleConfig<NitroTypes>;
|
||
/** The tracing channels Nuxt owns, enabled independently of the server runtime's own. */
|
||
interface TracingChannelOptionsBase {
|
||
/** Enable Nuxt-owned `nuxt.*` channels. */
|
||
nuxt?: boolean;
|
||
}
|
||
/** @internal */
|
||
type ResolveTracingChannelOptions<T> = TracingChannelOptionsBase & (T extends {
|
||
tracingChannels: infer C;
|
||
} ? C : Record<string, boolean | undefined>);
|
||
/**
|
||
* Per-channel toggles for `tracingChannel`. Channel names follow the
|
||
* [untracing](https://github.com/unjs/untracing) naming convention (`{namespace}.{operation}`).
|
||
*
|
||
* @experimental Channel names, payload shapes, and option keys may change.
|
||
*/
|
||
type TracingChannelOptions = ResolveTracingChannelOptions<NitroTypes>;
|
||
/** Prerender options shared by every server builder. */
|
||
interface PrerenderOptions {
|
||
/** Routes to prerender, in addition to those discovered by crawling or matched by `prerender` route rules. */
|
||
routes?: string[];
|
||
/** Routes to skip. A string matches as a path prefix. */
|
||
ignore?: Array<string | RegExp | ((path: string) => boolean | null | undefined)>;
|
||
/** Follow links in each rendered page to discover further routes. */
|
||
crawlLinks?: boolean;
|
||
}
|
||
/**
|
||
* Fallback configuration shape, limited to the keys Nuxt itself reads and writes. A server
|
||
* builder typically accepts a far wider set, which it describes itself.
|
||
*
|
||
* Members must be registry-independent: a member typed through a {@link NitroTypes} or
|
||
* `ServerTypes` key stops describing the fallback as soon as a builder's augments are in the
|
||
* program.
|
||
*/
|
||
interface NitroConfigFallback {
|
||
virtual?: Record<string, string | (() => string | Promise<string>)>;
|
||
plugins?: string[];
|
||
output?: {
|
||
dir?: string;
|
||
publicDir?: string;
|
||
serverDir?: string;
|
||
};
|
||
runtimeConfig?: Record<string, unknown>;
|
||
handlers?: ServerHandlerFallback[];
|
||
devHandlers?: DevServerHandlerFallback[];
|
||
imports?: false | ServerImportsOptions;
|
||
scanDirs?: string[];
|
||
routeRules?: Record<string, RouteRuleConfigFallback>;
|
||
prerender?: PrerenderOptions & {
|
||
failOnError?: boolean;
|
||
};
|
||
static?: boolean;
|
||
typescript?: {
|
||
tsConfig?: Record<string, any>;
|
||
generateTsConfig?: boolean;
|
||
strict?: boolean;
|
||
};
|
||
tracingChannel?: boolean | (TracingChannelOptionsBase & Record<string, boolean | undefined>);
|
||
experimental?: {
|
||
envExpansion?: boolean;
|
||
};
|
||
rollupConfig?: {
|
||
plugins?: unknown;
|
||
};
|
||
}
|
||
/** @internal */
|
||
type ResolveNitroConfig<T> = T extends {
|
||
config: infer C;
|
||
} ? C : NitroConfigFallback;
|
||
/** The configuration of the server build, as accepted by the configured `server.builder`. */
|
||
type NitroConfig = ResolveNitroConfig<NitroTypes>;
|
||
interface DeprecatedNitroPrerenderOptions {
|
||
/** @deprecated Use the top-level `prerender.routes` option instead. */
|
||
routes?: PrerenderOptions["routes"];
|
||
/** @deprecated Use the top-level `prerender.ignore` option instead. */
|
||
ignore?: PrerenderOptions["ignore"];
|
||
/** @deprecated Use the top-level `prerender.crawlLinks` option instead. */
|
||
crawlLinks?: PrerenderOptions["crawlLinks"];
|
||
}
|
||
type NitroConfigKey<T, K extends PropertyKey> = K extends keyof T ? T[K] : never;
|
||
interface DeprecatedNitroOptions<T> {
|
||
/** @deprecated Use the top-level `runtimeConfig` option instead. */
|
||
runtimeConfig?: NitroConfigKey<T, "runtimeConfig">;
|
||
/** @deprecated Use the top-level `routeRules` option instead. */
|
||
routeRules?: NitroConfigKey<T, "routeRules">;
|
||
/** @deprecated Use the top-level `tracingChannel` option instead. */
|
||
tracingChannel?: NitroConfigKey<T, "tracingChannel">;
|
||
typescript?: Omit<NonNullable<NitroConfigKey<T, "typescript">>, "tsConfig"> & {
|
||
/** @deprecated Use the top-level `typescript.serverTsConfig` option instead. */
|
||
tsConfig?: NonNullable<NitroConfigKey<T, "typescript">> extends {
|
||
tsConfig?: infer C;
|
||
} ? C : never;
|
||
};
|
||
prerender?: Omit<NonNullable<NitroConfigKey<T, "prerender">>, keyof PrerenderOptions> & DeprecatedNitroPrerenderOptions;
|
||
}
|
||
/** @internal */
|
||
type ResolveNuxtNitroConfig<T> = Omit<T, keyof DeprecatedNitroOptions<T>> & DeprecatedNitroOptions<T>;
|
||
/**
|
||
* Fallback options shape, describing the subset of resolved options common to the supported
|
||
* nitro majors. Used when no server builder has contributed an instance type.
|
||
*
|
||
* Members must be registry-independent, as on {@link NitroConfigFallback}.
|
||
*/
|
||
interface NitroInstanceOptionsFallback {
|
||
handlers: ServerHandlerFallback[];
|
||
devHandlers: DevServerHandlerFallback[];
|
||
runtimeConfig: Record<string, any>;
|
||
plugins: string[];
|
||
alias: Record<string, string>;
|
||
virtual: Record<string, any>;
|
||
publicAssets: Array<{
|
||
dir: string;
|
||
baseURL?: string;
|
||
} & Record<string, any>>;
|
||
routeRules: Record<string, Record<string, any>>;
|
||
prerender: Record<string, any>;
|
||
output: Record<string, any>;
|
||
storage?: Record<string, any>;
|
||
devStorage?: Record<string, any>;
|
||
static?: boolean;
|
||
node?: boolean;
|
||
baseURL?: string;
|
||
preset?: string;
|
||
dev: boolean;
|
||
typescript?: NitroConfigFallback["typescript"];
|
||
_config?: Record<string, any>;
|
||
rollupConfig?: Record<string, any>;
|
||
ssrRoutes?: string[];
|
||
}
|
||
/**
|
||
* Fallback instance shape, describing the subset of the nitro instance common to the
|
||
* supported nitro majors. Used when no server builder has contributed an instance type.
|
||
*
|
||
* Members must be registry-independent, as on {@link NitroConfigFallback}.
|
||
*/
|
||
interface NitroInstanceFallback {
|
||
meta: {
|
||
version: string;
|
||
majorVersion: number;
|
||
};
|
||
options: NitroInstanceOptionsFallback;
|
||
scannedHandlers: Array<Record<string, any>>;
|
||
vfs: Record<string, string> | Map<string, {
|
||
render: () => string | Promise<string>;
|
||
}>;
|
||
hooks: {
|
||
hook: (...args: any[]) => () => void;
|
||
hookOnce: (...args: any[]) => () => void;
|
||
callHook: (...args: any[]) => void | Promise<any>;
|
||
addHooks: (...args: any[]) => () => void;
|
||
removeHook: (...args: any[]) => void;
|
||
};
|
||
logger: {
|
||
log: (...args: any[]) => void;
|
||
info: (...args: any[]) => void;
|
||
warn: (...args: any[]) => void;
|
||
error: (...args: any[]) => void;
|
||
} & Record<string, any>;
|
||
/** Only available on nitro v3. */
|
||
fetch?: (input: Request) => Response | Promise<Response>;
|
||
/** Only available on nitro v3. */
|
||
routing?: {
|
||
sync: () => void;
|
||
routeRules: {
|
||
routes: Array<{
|
||
route: string;
|
||
data: Record<string, any>;
|
||
}>;
|
||
} & Record<string, any>;
|
||
} & Record<string, any>;
|
||
/** Only available on nitro v2. */
|
||
storage?: unknown;
|
||
unimport?: unknown;
|
||
updateConfig: (config: Record<string, any>) => void | Promise<void>;
|
||
close: () => Promise<void>;
|
||
}
|
||
/**
|
||
* Resolves the instance type contributed to a {@link NitroTypes} registry, or {@link NitroInstanceFallback}
|
||
* when the registry does not declare one. Exported for type tests; not part of the public API.
|
||
*
|
||
* @internal
|
||
*/
|
||
type ResolveNitroInstance<T> = T extends {
|
||
instance: infer I;
|
||
} ? I : NitroInstanceFallback;
|
||
/**
|
||
* Resolves the options of a nitro instance type, or {@link NitroInstanceOptionsFallback} when the instance
|
||
* does not declare them. Exported for type tests; not part of the public API.
|
||
*
|
||
* @internal
|
||
*/
|
||
type ResolveNitroInstanceOptions<T> = T extends {
|
||
options: infer O;
|
||
} ? O : NitroInstanceOptionsFallback;
|
||
/**
|
||
* The nitro instance handed out by `useNitro()`, as declared by the configured
|
||
* `server.builder`, or {@link NitroInstanceFallback} when none has declared it.
|
||
*
|
||
* Registrations accepted by `@nuxt/kit`'s nitro utilities are described by that package; this is
|
||
* only the running instance, whose type is the server builder's to declare.
|
||
*/
|
||
type NitroInstance = ResolveNitroInstance<NitroTypes>;
|
||
/** The resolved options of the nitro instance handed out by `useNitro()`. */
|
||
type NitroInstanceOptions = ResolveNitroInstanceOptions<NitroInstance>;
|
||
interface NuxtCompatibility {
|
||
/**
|
||
* Required nuxt version in semver format.
|
||
* @example `^3.2.0` or `>=3.13.0`.
|
||
*/
|
||
nuxt?: string;
|
||
/**
|
||
* Required nitro version in semver format.
|
||
*
|
||
* Like `nuxt`, this is a requirement check only: the module is disabled when the host
|
||
* nitro does not satisfy the range. It says nothing about which server API the module's
|
||
* runtime code uses; see `server` for that.
|
||
* @example `>=2.0.0` or `^3.0.0`.
|
||
*/
|
||
nitro?: string;
|
||
/**
|
||
* The server API the module's runtime code is written against, for every server
|
||
* registration the module makes and every file under its runtime directories.
|
||
*
|
||
* Usually unnecessary: a file's imports say which API it uses (`nuxt/server`, `nitro/*`
|
||
* or `h3`/`nitropack`). Undeclared and uninferrable code is treated as `nitro2`.
|
||
*/
|
||
server?: ServerApi;
|
||
/**
|
||
* Mark a builder as incompatible, or require a particular version.
|
||
*
|
||
* @example
|
||
* ```ts
|
||
* export default defineNuxtModule({
|
||
* meta: {
|
||
* name: 'my-module',
|
||
* compatibility: {
|
||
* builder: {
|
||
* // marking as incompatible
|
||
* webpack: false,
|
||
* // you can require a (semver-compatible) version
|
||
* vite: '^5'
|
||
* }
|
||
* }
|
||
* }
|
||
* // ...
|
||
* })
|
||
* ```
|
||
*/
|
||
builder?: Partial<Record<"vite" | "webpack" | "rspack" | (string & {}), false | string>>;
|
||
}
|
||
interface NuxtCompatibilityIssue {
|
||
name: string;
|
||
message: string;
|
||
}
|
||
interface NuxtCompatibilityIssues extends Array<NuxtCompatibilityIssue> {
|
||
/**
|
||
* Return formatted error message.
|
||
*/
|
||
toString(): string;
|
||
}
|
||
export { NuxtConfigInput as $, ResolvedNuxtTemplate as $t, TracingChannelOptions as A, KeyedFunctionFactory as An, NuxtLayout as At, ServerEventHandler as B, NuxtImportDeclarationType as Bn, NuxtPlugin as Bt, ServerHandlerFallback as C, Component as Cn, GenerateAppOptions as Ct, ServerPlugin as D, ScanDir as Dn, NuxtAnalyzeMeta as Dt, ServerImportsOptions as E, ComponentsOptions as En, ModuleInstallInfo as Et, NuxtRequestContext as F, RouterOptions$1 as Fn, VueTSConfig as Ft, ServerTypes as G, NuxtImportScanDir as Gn, NuxtServerBuildOutput as Gt, ServerRouteHandler as H, NuxtImportPreset as Hn, NuxtServerBuild as Ht, NuxtRequestEvent as I, ImportsOptions as In, WatchEvent as It, CustomAppConfig as J, NuxtServerTemplate as Jt, AppConfig$1 as K, NuxtImportScanOptions as Kn, NuxtServerBuildPreview as Kt, NuxtServerHooks as L, NuxtImport as Ln, Nuxt as Lt, AppRouteRules as M, NuxtLinkOptions as Mn, NuxtPage as Mt, AppRouteRulesBase as N, RouterConfig as Nn, NuxtPageMeta as Nt, ServerPluginInput as O, CompilerScanDir as On, NuxtHookName as Ot, AppRouteRulesExtensions as P, RouterConfigSerializable as Pn, TSReference as Pt, NuxtConfig as Q, NuxtTypeTemplate as Qt, RequestEvent as R, NuxtImportAddonsOptions as Rn, NuxtApp as Rt, ServerHandlerEnv as S, NuxtManifestResource as Sn, MetaObjectRaw as St, ServerHandlerMethod as T, ComponentsDir as Tn, ImportPresetWithDeprecation as Tt, ServerRouteSegment as U, NuxtImportPresetName as Un, NuxtServerBuildCapabilities as Ut, ServerRequestTypes as V, NuxtImportEntry as Vn, NuxtPluginTemplate as Vt, ServerRoutes as W, NuxtImportPresetSource as Wn, NuxtServerBuildInput as Wt, NuxtAppConfig as X, NuxtTemplateChange as Xt, DefineNuxtConfig as Y, NuxtTemplate as Yt, NuxtBuilder as Z, NuxtTemplateDependency as Zt, RouteRuleConfigExtensions as _, NuxtHookKeys as _n, NuxtDotenvOptions as _t, DevServerHandlerFallback as a, ModuleDependencyMeta as an, SchemaDefinition$1 as at, ServerApiVariants as b, NuxtNestedHooks as bn, AppHeadMetaObject as bt, NitroConfig as c, ModuleSetupInstallResult as cn, ViewTransitionOptions as ct, NitroInstanceFallback as d, ResolvedModuleOptions as dn, ViteOptions as dt, NuxtDebugContext as en, NuxtOptions as et, NitroInstanceOptions as f, NuxtIgnoreMatcher as fn, VitePlugin as ft, RouteRuleConfig as g, NuxtHookCallback as gn, NuxtConfigLayerMeta as gt, PrerenderOptions as h, NuxtDeprecatedHook as hn, NuxtConfigLayer as ht, DevServerHandler as i, ModuleDependencies as in, RuntimeValue as it, TracingChannelOptionsBase as j, NuxtCompilerOptions as jn, NuxtMiddleware as jt, ServerRouteMeta as k, KeyedFunction as kn, NuxtHooks as kt, NitroConfigFallback as l, ModuleSetupReturn as ln, ViewTransitionPageOptions as lt, NitroTypes as m, NuxtIgnoreTestResult as mn, WebpackPluginInstance$1 as mt, NuxtCompatibilityIssue as n, NuxtDebugOptions as nn, RuntimeConfig as nt, DevServerHandlerFunction as o, ModuleMeta as on, SharedAppConfig as ot, NitroInstanceOptionsFallback as p, NuxtIgnoreOptions as pn, WebpackConfig as pt, AppConfigInput as q, NuxtPackageImportPreset as qn, NuxtServerBuildRuntime as qt, NuxtCompatibilityIssues as r, ModuleDefinition as rn, RuntimeConfigApp as rt, DevServerHandlerInput as s, ModuleOptions as sn, UpperSnakeCase as st, NuxtCompatibility as t, NuxtDebugModuleMutationRecord as tn, PublicRuntimeConfig as tt, NitroInstance as u, NuxtModule as un, ViteConfig as ut, RouteRuleConfigFallback as v, NuxtHookRegistry as vn, NuxtLayerSourceOptions as vt, ServerHandlerInput as w, ComponentMeta as wn, HookResult as wt, ServerHandler as x, NuxtManifest as xn, MetaObject as xt, ServerApi as y, NuxtHookSpyEvent as yn, ConfigSchema as yt, RequestEventContext as z, NuxtImportCommon as zn, NuxtBuildOutputs as zt }; |