You can improve your DX by defining additional aliases to access custom directories within your JavaScript and CSS.
object{
"~": "/<srcDir>/",
"@": "/<srcDir>/",
"~~": "/<rootDir>/",
"@@": "/<rootDir>/",
"#shared": "/<rootDir>/shared/",
"assets": "/<srcDir>/assets/",
"public": "/<srcDir>/public/",
"#build": "/<rootDir>/.nuxt/",
"#internal/nuxt/paths": "/<rootDir>/.nuxt/paths.mjs"
}
~..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:
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))
}
}
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.
string"/<rootDir>/.nuxt/analyze"Nuxt App configuration.
baseURLThe base path of your Nuxt application.
For example:
string"/"Example:
export default defineNuxtConfig({
app: {
baseURL: '/prefix/'
}
})
Example:
NUXT_APP_BASE_URL=/prefix/ node .output/server/index.mjs
buildAssetsDirThe 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.
string"/_nuxt/"cdnURLAn absolute URL to serve the public folder from (production-only).
For example:
string""Example:
export default defineNuxtConfig({
app: {
cdnURL: 'https://mycdn.org/'
}
})
Example:
NUXT_APP_CDN_URL=https://mycdn.org/ node .output/server/index.mjs
headSet default configuration for <head> on every page.
object{
"meta": [
{
"name": "viewport",
"content": "width=device-width, initial-scale=1"
},
{
"charset": "utf-8"
}
],
"link": [],
"style": [],
"script": [],
"noscript": []
}
Example:
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' }
]
}
}
keepaliveDefault values for KeepAlive configuration between pages.
This can be overridden with definePageMeta on an individual page. Only JSON-serializable values are allowed.
booleanfalseSee: Vue KeepAlive
layoutTransitionDefault values for layout transitions.
This can be overridden with definePageMeta on an individual page. Only JSON-serializable values are allowed.
booleanfalseSee: Vue Transition docs
pageTransitionDefault values for page transitions.
This can be overridden with definePageMeta on an individual page. Only JSON-serializable values are allowed.
booleanfalseSee: Vue Transition docs
rootAttrsCustomize Nuxt root element id.
object{
"id": "__nuxt"
}
rootIdCustomize Nuxt root element id.
string"__nuxt"rootTagCustomize Nuxt root element tag.
string"div"spaLoaderAttrsCustomize Nuxt Nuxt SpaLoader element attributes.
idstring"__nuxt-loader"spaLoaderTagCustomize Nuxt SpaLoader element tag.
string"div"teleportAttrsCustomize Nuxt Teleport element attributes.
object{
"id": "teleports"
}
teleportIdCustomize Nuxt Teleport element id.
string"teleports"teleportTagCustomize Nuxt Teleport element tag.
string"div"viewTransitionDefault values for view transitions.
This only has an effect when experimental support for View Transitions is enabled in your nuxt.config file.
This can be overridden with definePageMeta on an individual page.
booleanfalseSee: Nuxt View Transition API docs
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.
nuxtFor multi-app projects, the unique id of the Nuxt application.
Defaults to nuxt-app.
string"nuxt-app"Shared build configuration.
analyzeNuxt allows visualizing your bundles and how to optimize them.
Set to true to enable bundle analysis, or pass an object with options: for webpack or for vite.
object{
"template": "treemap",
"projectRoot": "/<rootDir>",
"filename": "/<rootDir>/.nuxt/analyze/{name}.html"
}
Example:
analyze: {
analyzerMode: 'static'
}
templatesIt is recommended to use addTemplate from @nuxt/kit instead of this option.
arrayExample:
templates: [
{
src: '~/modules/support/plugin.js', // `src` can be absolute or relative
dst: 'support.js', // `dst` is relative to project `.nuxt` dir
}
]
transpileIf 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 }).
arrayExample:
transpile: [({ isLegacy }) => isLegacy && 'ky']
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.
string"/<rootDir>/.nuxt"Example:
export default {
buildDir: 'nuxt-build'
}
A unique identifier matching the build. This may contain the hash of the current state of the project.
string"84cde2e2-8b76-4234-80e5-67c2dd45206f"The builder to use for bundling the Vue part of your application.
string"@nuxt/vite-builder"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.
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.
object{
"dirs": [
{
"path": "~/components/global",
"global": true
},
"~/components"
]
}
See: components/ directory documentation
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.
arrayExample:
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'
]
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.
booleanfalseWhether Nuxt is running in development mode.
Normally, you should not need to set this.
booleanfalsecorsSet CORS options for the dev server
originarray[
{}
]
hostDev server listening host
httpsWhether to enable HTTPS.
booleanfalseExample:
export default defineNuxtConfig({
devServer: {
https: {
key: './server.key',
cert: './server.crt'
}
}
})
loadingTemplateTemplate to show a loading screen
functionportDev server listening port
number3000urlListening 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).
string"http://localhost:3000"Nitro development-only server handlers.
arraySee: Nitro server routes documentation
Enable Nuxt DevTools for development.
Breaking changes for devtools might not reflect on the version of Nuxt.
See: Nuxt DevTools for more information.
Customize default directory structure used by Nuxt.
It is better to stick with defaults unless needed.
appstring"app"assetsThe assets directory (aliased as ~assets in your build).
string"assets"layoutsThe layouts directory, each file of which will be auto-registered as a Nuxt layout.
string"layouts"middlewareThe middleware directory, each file of which will be auto-registered as a Nuxt middleware.
string"middleware"modulesThe modules directory, each file in which will be auto-registered as a Nuxt module.
string"modules"pagesThe directory which will be processed to auto-generate your application page routes.
string"pages"pluginsThe plugins directory, each file of which will be auto-registered as a Nuxt plugin.
string"plugins"publicThe 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.
string"public"sharedThe shared directory. This directory is shared between the app and the server.
string"shared"staticstring"public"optionsConfigure shared esbuild options used within Nuxt and passed to other builders, such as Vite or Webpack.
jsxFactorystring"h"jsxFragmentstring"Fragment"targetstring"esnext"tsconfigRawobjectalwaysRunFetchOnKeyChangeWhether 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.
booleantrueappManifestUse app manifests to respect route rules on client-side.
booleantrueasyncContextEnable native async context to be accessible for nested composables
booleanfalseSee: Nuxt PR #20918
asyncEntrySet to true to generate an async entry point for the Vue bundle (for module federation support).
booleanfalsebrowserDevtoolsTimingEnable 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.
booleanfalseExample:
// nuxt.config.ts
export default defineNuxtConfig({
experimental: {
// Enable performance markers for Nuxt hooks in browser devtools
browserDevtoolsTiming: true
}
})
See: PR #29922
See: Chrome DevTools Performance API
buildCacheCache 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.
booleanfalsecheckOutdatedBuildIntervalSet the time interval (in ms) to check for new builds. Disabled when experimental.appManifest is false.
Set to false to disable.
number3600000chromeDevtoolsProjectSettingsEnable integration with Chrome DevTools Workspaces for Nuxt projects.
booleantrueSee: Chrome DevTools Project Settings
clientFallbackWhether to enable the experimental <NuxtClientFallback> component for rendering content on the client if there's an error in SSR.
booleanfalseclientNodeCompatAutomatically polyfill Node.js imports in the client build using unenv.
booleanfalseSee: unenv
compileTemplateWhether to use lodash.template to compile Nuxt templates.
This flag will be removed with the release of v4 and exists only for advance testing within Nuxt v3.12+ or in the nightly release channel.
booleantruecomponentIslandsExperimental 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.
string"auto"configSchemaConfig schema support
booleantrueSee: Nuxt Issue #15592
cookieStoreEnables CookieStore support to listen for cookie updates (if supported by the browser) and refresh useCookie ref values.
booleantrueSee: CookieStore
crossOriginPrefetchEnable cross-origin prefetch using the Speculation Rules API.
booleanfalsedebugModuleMutationRecord 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.
booleanfalseExample:
// nuxt.config.ts
export default defineNuxtConfig({
experimental: {
// Enable tracking of config mutations by modules
debugModuleMutation: true
}
})
See: PR #30555
decoratorsEnable to use experimental decorators in Nuxt and Nitro.
booleanfalseSee: https://github.com/tc39/proposal-decorators
defaultsThis 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.
nuxtLinkcomponentNamestring"NuxtLink"prefetchbooleantrueprefetchOnvisibilitybooleantrueuseAsyncDataOptions that apply to useAsyncData (and also therefore useFetch)
deepbooleantrueerrorValuestring"null"valuestring"null"useFetchemitRouteChunkErrorEmit 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.
string"automatic"See: Nuxt PR #19038
enforceModuleCompatibilityWhether Nuxt should stop if a Nuxt module is incompatible.
booleanfalseentryImportMapbooleantrueexternalVueExternalize vue, @vue/* and vue-router when building.
booleantrueSee: Nuxt Issue #13632
extraPageMetaExtractionKeysConfigure 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.
arrayextractAsyncDataHandlersbooleanfalsegranularCachedDataWhether to call and use the result from getCachedData on manual refresh for useAsyncData and useFetch.
booleanfalseheadNextUse new experimental head optimisations:
booleantrueinlineRouteRulesAllow 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.
booleanfalselazyHydrationEnable 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.
booleantrueExample:
// 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
localLayerAliasesResolve ~, ~~, @ and @@ aliases located within layers with respect to their layer source and root directories.
booleantruenavigationRepaintWait 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.
booleantruenoVueServerDisable vue server renderer endpoint within nitro.
booleanfalsenormalizeComponentNamesEnsure that auto-generated Vue component names match the full component name you would use to auto-import the component.
booleanfalseparseErrorDataWhether to parse error.data when rendering a server error page.
booleanfalsepayloadExtractionWhen this option is enabled (by default) payload of pages that are prerendered are extracted
booleantruependingWhenIdleFor useAsyncData and useFetch, whether pending should be true when data has not yet started to be fetched.
booleantruepolyfillVueUseHeadWhether or not to add a compatibility layer for modules, plugins or user code relying on the old @vueuse/head API.
This is disabled to reduce the client-side bundle by ~0.5kb.
booleanfalsepurgeCachedDataWhether 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.
booleantrueExample:
// nuxt.config.ts
export default defineNuxtConfig({
experimental: {
// Disable automatic cache cleanup (default is true)
purgeCachedData: false
}
})
See: PR #31379
relativeWatchPathsWhether to provide relative paths in the builder:watch hook.
This flag will be removed with the release of v4 and exists only for advance testing within Nuxt v3.12+ or in the nightly release channel.
booleantruerenderJsonPayloadsRender JSON payloads with support for revivifying complex types.
booleantrueresetAsyncDataToUndefinedWhether clear and clearNuxtData should reset async data to its default value or update it to null/undefined.
booleantruerespectNoSSRHeaderAllow disabling Nuxt SSR responses by setting the x-nuxt-no-ssr header.
booleanfalserestoreStateWhether 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.
booleanfalsescanPageMetaAllow 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.
booleantrueSee: Nuxt Issues #24770
sharedPrerenderDataAutomatically 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.)
booleanfalseExample:
// 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}`)
})
spaLoadingTemplateLocationKeep showing the spa-loading-template until suspense:resolve
string"within"See: Nuxt Issues #21721
templateImportResolutionDisable 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.
booleantrueExample:
// nuxt.config.ts
export default defineNuxtConfig({
experimental: {
// Disable template import resolution from module path
templateImportResolution: false
}
})
See: PR #31175
templateRouteInjectionBy 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().
booleantruetemplateUtilsWhether to provide a legacy templateUtils object (with serialize, importName and importSources) when compiling Nuxt templates.
This flag will be removed with the release of v4 and exists only for advance testing within Nuxt v3.12+ or in the nightly release channel.
booleantruetreeshakeClientOnlyTree shakes contents of client-only components from server bundle.
booleantrueSee: Nuxt PR #5750
typedPagesEnable the new experimental typed router using unplugin-vue-router.
booleanfalseviewTransitionEnable View Transition API integration with client-side router.
booleanfalseSee: View Transitions API
viteEnvironmentApibooleanfalsewatcherSet 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.
string"chokidar"See: chokidar
See: @parcel/watcher
writeEarlyHintsWrite early hints when using node server.
booleanfalseExtend 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: c12 docs on extending config layers
See: giget documentation
The extensions that should be resolved by the Nuxt resolver.
array[
".js",
".jsx",
".mjs",
".ts",
".tsx",
".vue"
]
Some features of Nuxt are available on an opt-in basis, or can be disabled based on your needs.
devLogsStream 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.
booleanfalseinlineStylesInline 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.
booleantruenoScriptsTurn 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.
booleanfalsefuture is for early opting-in to new features that will become default in a future (possibly major) version of the framework.
compatibilityVersionEnable early access to Nuxt v4 features or flags.
Setting compatibilityVersion to 4 changes defaults throughout your Nuxt configuration, but you can granularly re-enable Nuxt v3 behaviour when testing (see example). Please file issues if so, so that we can address in Nuxt or in the ecosystem.
number3Example:
export default defineNuxtConfig({
future: {
compatibilityVersion: 4,
},
// To re-enable _all_ Nuxt v3 behaviour, set the following options:
srcDir: '.',
dir: {
app: 'app'
},
experimental: {
compileTemplate: true,
templateUtils: true,
relativeWatchPaths: true,
resetAsyncDataToUndefined: true,
defaults: {
useAsyncData: {
deep: true
}
}
},
unhead: {
renderSSRHeadOptions: {
omitLineBreaks: false
}
}
})
multiAppThis enables early access to the experimental multi-app support.
booleanfalseSee: Nuxt Issue #21635
typescriptBundlerResolutionThis 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.
booleantrueSee: TypeScript PR implementing bundler module resolution
excludeThis option is no longer used. Instead, use nitro.prerender.ignore.
arrayroutesThe routes to generate.
If you are using the crawler, this will be only the starting point for route generation. This is often necessary when using dynamic routes.
It is preferred to use nitro.prerender.routes.
arrayExample:
routes: ['/users/1', '/users/2', '/users/3']
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:
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')
}
}
}
}
More customizable than ignorePrefix: all files matching glob patterns specified inside the ignore array will be ignored in building.
array[
"**/*.stories.{js,cts,mts,ts,jsx,tsx}",
"**/*.{spec,test}.{js,cts,mts,ts,jsx,tsx}",
"**/*.d.{cts,mts,ts}",
"**/.{pnpm-store,vercel,netlify,output,git,cache,data}",
"**/*.sock",
".nuxt/analyze",
".nuxt",
"**/-*.*"
]
Pass options directly to node-ignore (which is used by Nuxt to ignore files).
See: node-ignore
Example:
ignoreOptions: {
ignorecase: false
}
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 '-'.
string"-"Configure how Nuxt auto-imports composables into your application.
See: Nuxt documentation
dirsAn array of custom directories that will be auto-imported. Note that this option will not override the default directories (~/composables, ~/utils).
arrayExample:
imports: {
// Auto-import pinia stores defined in `~/stores`
dirs: ['stores']
}
globalbooleanfalsescanWhether to scan your composables/ and utils/ directories for composables to auto-import. Auto-imports registered by Nuxt or other modules, such as imports from vue or nuxt, will still be enabled.
booleantrueLog 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
string"info"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.
arraynuxt.config.ts are loaded. Then, modules found in the modules/
directory are executed, and they load in alphabetical order.Example:
modules: [
// Using package name
'@nuxtjs/axios',
// Relative to your project srcDir
'~/modules/awesome.js',
// Providing options
['@nuxtjs/google-analytics', { ua: 'X1234567' }],
// Inline definition
function () {}
]
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.
array[
"/<rootDir>/node_modules"
]
Example:
export default {
modulesDir: ['../../node_modules']
}
Configuration for Nitro.
routeRulesobjectruntimeConfigobject{
"public": {},
"app": {
"buildId": "84cde2e2-8b76-4234-80e5-67c2dd45206f",
"baseURL": "/",
"buildAssetsDir": "/_nuxt/",
"cdnURL": ""
},
"nitro": {
"envPrefix": "NUXT_"
}
}
Build time optimization configuration.
asyncTransformsOptions passed directly to the transformer from unctx that preserves async context after await.
asyncFunctionsarray[
"defineNuxtPlugin",
"defineNuxtRouteMiddleware"
]
objectDefinitionsdefineNuxtComponentarray[
"asyncData",
"setup"
]
defineNuxtPluginarray[
"setup"
]
definePageMetaarray[
"middleware",
"validate"
]
keyedComposablesFunctions to inject a key for.
As long as the number of arguments passed to the function is less 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.
array[
{
"name": "callOnce",
"argumentLength": 3
},
{
"name": "defineNuxtComponent",
"argumentLength": 2
},
{
"name": "useState",
"argumentLength": 2
},
{
"name": "useFetch",
"argumentLength": 3
},
{
"name": "useAsyncData",
"argumentLength": 3
},
{
"name": "useLazyAsyncData",
"argumentLength": 3
},
{
"name": "useLazyFetch",
"argumentLength": 3
}
]
treeShakeTree shake code from specific builds.
composablesTree shake composables from the server or client builds.
Example:
treeShake: { client: { myPackage: ['useServerOnlyComposable'] } }
clientobject{
"vue": [
"onRenderTracked",
"onRenderTriggered",
"onServerPrefetch"
],
"#app": [
"definePayloadReducer",
"definePageMeta",
"onPrehydrate"
]
}
serverobject{
"vue": [
"onMounted",
"onUpdated",
"onUnmounted",
"onBeforeMount",
"onBeforeUpdate",
"onBeforeUnmount",
"onRenderTracked",
"onRenderTriggered",
"onActivated",
"onDeactivated"
],
"#app": [
"definePayloadReviver",
"definePageMeta"
]
}
Configure shared oxc options used within Nuxt and passed where necessary.
transformOptions for oxc-transform
See: Oxc transform docs
optionsjsxFactorystring"h"jsxFragmentstring"Fragment"targetstring"esnext"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:
pages: {
pattern: ['**\/*\/*.vue', '!**\/*.spec.*'],
}
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.
array~/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
Example:
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
]
orderA strategy for ordering PostCSS plugins.
functionpluginsOptions for configuring PostCSS plugins.
See: PostCSS docs
autoprefixerPlugin to parse CSS and add vendor prefixes to CSS rules.
See: autoprefixer
cssnanoobjectSee: cssnano configuration options
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.
string"/<rootDir>"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
optionsAdditional router options passed to vue-router. On top of the options for vue-router, Nuxt offers additional options to customize the router (see below).
app/router.options.ts file.See: Vue Router documentation.
hashModeYou can enable hash history in SPA mode. In this mode, router uses a hash character (#) before the actual URL that is internally passed. When enabled, the URL is never sent to the server and SSR is not supported.
booleanfalseDefault: false
scrollBehaviorTypeCustomize the scroll behavior for hash links.
string"auto"Default: 'auto'
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.
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.
object{
"public": {},
"app": {
"buildId": "84cde2e2-8b76-4234-80e5-67c2dd45206f",
"baseURL": "/",
"buildAssetsDir": "/_nuxt/",
"cdnURL": ""
}
}
Example:
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.
}
}
}
builderstring"@nuxt/nitro-server"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.
string"/<srcDir>/server"Nitro server handlers.
Each handler accepts the following options:
arraySee: server/ directory documentation
server/api, server/middleware and server/routes will be automatically registered by Nuxt.Example:
serverHandlers: [
{ route: '/path/foo/**:name', handler: '~/server/foohandler.ts' }
]
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.
object{
"server": true,
"client": false
}
Boolean or a path to an HTML file with the contents of which will be inserted into any HTML page rendered with ssr: false.
~/app/spa-loading-template.html file in one of your layers, if it exists. - If it is false, no SPA loading indicator will be loaded. - If true, Nuxt will look for ~/app/spa-loading-template.html file in one of your layers, or a
default Nuxt image will be used.
Some good sources for spinners are SpinKit or SVG Spinners.nullExample: ~/app/spa-loading-template.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>
Define the source directory of your Nuxt application.
If a relative path is specified, it will be relative to the rootDir.
string"/<srcDir>"Example:
export default {
srcDir: 'src/'
}
This would work with the following folder structure:
-| app/
---| node_modules/
---| nuxt.config.js
---| package.json
---| src/
------| assets/
------| components/
------| layouts/
------| middleware/
------| pages/
------| plugins/
------| public/
------| store/
------| server/
------| app.config.ts
------| app.vue
------| error.vue
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.
booleantrueManually disable nuxt telemetry.
See: Nuxt Telemetry for more information.
Whether your app is being unit tested.
booleanfalseExtend 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.
stringConfiguration for Nuxt's TypeScript integration.
builderWhich 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.
nullhoistModules 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.
array[
"nitropack/types",
"nitropack/runtime",
"nitropack",
"defu",
"h3",
"consola",
"ofetch",
"@unhead/vue",
"@nuxt/devtools",
"vue",
"@vue/runtime-core",
"@vue/compiler-sfc",
"vue-router",
"vue-router/auto-routes",
"unplugin-vue-router/client",
"@nuxt/schema",
"nuxt"
]
includeWorkspaceInclude parent workspace in the Nuxt project. Mostly useful for themes and module authors.
booleanfalseshimGenerate a *.vue shim.
We recommend instead letting the official Vue extension 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.
booleanfalsestrictTypeScript 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
booleantruetsConfigYou can extend generated .nuxt/tsconfig.json using this option.
typeCheckEnable 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.
booleanfalseSee: Nuxt TypeScript docs
An object that allows us to configure the unhead nuxt module.
legacyEnable the legacy compatibility mode for unhead module. This applies the following changes: - Disables Capo.js sorting - Adds the DeprecationsPlugin: supports hid, vmid, children, body - Adds the PromisesPlugin: supports promises as input
booleanfalseSee: unhead migration documentation
Example:
export default defineNuxtConfig({
unhead: {
legacy: true
})
renderSSRHeadOptionsAn object that will be passed to renderSSRHead to customize the output.
object{
"omitLineBreaks": false
}
Example:
export default defineNuxtConfig({
unhead: {
renderSSRHeadOptions: {
omitLineBreaks: true
}
})
Configuration that will be passed directly to Vite.
See: Vite configuration docs for more information. Please note that not all vite options are supported in Nuxt.
buildassetsDirstring"_nuxt/"emptyOutDirbooleanfalsecacheDirstring"/<rootDir>/node_modules/.cache/vite"clearScreenbooleantruedefineobject{
"__VUE_PROD_HYDRATION_MISMATCH_DETAILS__": false,
"process.dev": false,
"import.meta.dev": false,
"process.test": false,
"import.meta.test": false
}
esbuildobject{
"target": "esnext",
"jsxFactory": "h",
"jsxFragment": "Fragment",
"tsconfigRaw": {}
}
modestring"production"optimizeDepsesbuildOptionsobject{
"target": "esnext",
"jsxFactory": "h",
"jsxFragment": "Fragment",
"tsconfigRaw": {}
}
excludearray[
"vue-demi"
]
publicDirbooleanfalseresolveextensionsarray[
".mjs",
".js",
".ts",
".jsx",
".tsx",
".json",
".vue"
]
rootstring"/<srcDir>"serverfsallowarray[
"/<rootDir>/.nuxt",
"/<srcDir>",
"/<rootDir>",
"/<workspaceDir>"
]
vuefeaturespropsDestructurebooleantrueisProductionbooleantruescripthoistStatictemplatecompilerOptionsobjecttransformAssetUrlsobject{
"video": [
"src",
"poster"
],
"source": [
"src"
],
"img": [
"src"
],
"image": [
"xlink:href",
"href"
],
"use": [
"xlink:href",
"href"
]
}
vueJsxobject{
"isCustomElement": {
"$schema": {
"title": "",
"description": "",
"tags": []
}
}
}
Vue.js config
compilerOptionsOptions for the Vue compiler that will be passed at build time.
See: Vue documentation
configIt 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
propsDestructureEnable reactive destructure for defineProps
booleantrueruntimeCompilerInclude Vue compiler in runtime bundle.
booleanfalsetransformAssetUrlsimagearray[
"xlink:href",
"href"
]
imgarray[
"src"
]
sourcearray[
"src"
]
usearray[
"xlink:href",
"href"
]
videoarray[
"src",
"poster"
]
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).
arrayThe watchers property lets you overwrite watchers configuration in your nuxt.config.
chokidarOptions to pass directly to chokidar.
See: chokidar
ignoreInitialbooleantrueignorePermissionErrorsbooleantruerewatchOnRawEventsAn array of event types, which, when received, will cause the watcher to restart.
webpackwatchOptions to pass directly to webpack.
See: webpack@4 watch options.
aggregateTimeoutnumber1000aggressiveCodeRemovalHard-replaces typeof process, typeof window and typeof document to tree-shake bundle.
booleanfalseanalyzeNuxt 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 or for vite.
object{
"template": "treemap",
"projectRoot": "/<rootDir>",
"filename": "/<rootDir>/.nuxt/analyze/{name}.html"
}
Example:
analyze: {
analyzerMode: 'static'
}
cssSourceMapEnables CSS source map support (defaults to true in development).
booleanfalsedevMiddlewareSee webpack-dev-middleware for available options.
statsstring"none"experimentsConfigure webpack experiments
extractCSSEnables Common CSS Extraction.
Using 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.
booleantrueExample:
export default {
webpack: {
extractCSS: true,
// or
extractCSS: {
ignoreOrder: true
}
}
}
Example:
export default {
webpack: {
extractCSS: true,
optimization: {
splitChunks: {
cacheGroups: {
styles: {
name: 'styles',
test: /\.(css|vue)$/,
chunks: 'all',
enforce: true
}
}
}
}
}
}
filenamesCustomize bundle filenames.
To understand a bit more about the use of manifests, take a look at webpack documentation.
Example:
filenames: {
chunk: ({ isDev }) => (isDev ? '[name].js' : '[id].[contenthash].js')
}
appfunctionchunkfunctioncssfunctionfontfunctionimgfunctionvideofunctionfriendlyErrorsSet to false to disable the overlay provided by FriendlyErrorsWebpackPlugin.
booleantruehotMiddlewareSee webpack-hot-middleware for available options.
loadersCustomize the options of Nuxt's integrated webpack loaders.
cssSee css-loader for available options.
esModulebooleanfalseimportLoadersnumber0urlfilterfunctioncssModulesSee css-loader for available options.
esModulebooleanfalseimportLoadersnumber0moduleslocalIdentNamestring"[local]_[hash:base64:5]"urlfilterfunctionesbuildobject{
"target": "esnext",
"jsxFactory": "h",
"jsxFragment": "Fragment",
"tsconfigRaw": {}
}
See: esbuild loader
fileSee: file-loader Options
Default:
{ esModule: false }
esModulebooleanfalselimitnumber1000fontUrlSee: file-loader Options
Default:
{ esModule: false }
esModulebooleanfalselimitnumber1000imgUrlSee: file-loader Options
Default:
{ esModule: false }
esModulebooleanfalselimitnumber1000less{
"sourceMap": false
}
See: less-loader Options
pugPlainSee: pug options
sassSee: sass-loader Options
Default:
{
sassOptions: {
indentedSyntax: true
}
}
sassOptionsindentedSyntaxbooleantruescss{
"sourceMap": false
}
See: sass-loader Options
stylus{
"sourceMap": false
}
vueSee vue-loader for available options.
compilerOptionsobjectpropsDestructurebooleantruetransformAssetUrlsobject{
"video": [
"src",
"poster"
],
"source": [
"src"
],
"img": [
"src"
],
"image": [
"xlink:href",
"href"
],
"use": [
"xlink:href",
"href"
]
}
vueStyle{
"sourceMap": false
}
optimizationConfigure webpack optimization.
minimizeSet minimize to false to disable all minimizers. (It is disabled in development by default).
booleantrueminimizerYou can set minimizer to a customized array of plugins.
runtimeChunkstring"single"splitChunksautomaticNameDelimiterstring"/"cacheGroupschunksstring"all"optimizeCSSOptimizeCSSAssets plugin options.
Defaults to true when extractCSS is enabled.
booleanfalseSee: css-minimizer-webpack-plugin documentation.
pluginsAdd webpack plugins.
arrayExample:
import webpack from 'webpack'
import { version } from './package.json'
// ...
plugins: [
new webpack.DefinePlugin({
'process.VERSION': version
})
]
postcssCustomize PostCSS Loader. same options as postcss-loader options
postcssOptionspluginsobject{
"autoprefixer": {},
"cssnano": {}
}
profileEnable the profiler in webpackbar.
It is normally enabled by CLI argument --profile.
booleanfalseSee: webpackbar.
serverURLPolyfillThe polyfill library to load to provide URL and URLSearchParams.
Defaults to 'url' (see package).
string"url"warningIgnoreFiltersFilters to hide build warnings.
arrayDefine 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.
string"/<workspaceDir>"