The Nuxt experimental features can be enabled in the Nuxt configuration file.
Internally, Nuxt uses @nuxt/schema to define these experimental features. You can refer to the API documentation or the source code for more information.
Enable native async context to be accessible for nested composables in Nuxt and in Nitro. This opens the possibility to use composables inside async composables and reduce the chance to get the Nuxt instance is unavailable error.
export default defineNuxtConfig({
experimental: {
asyncContext: true,
},
})
Enables generation of an async entry point for the Vue bundle, aiding module federation support.
export default defineNuxtConfig({
experimental: {
asyncEntry: true,
},
})
Externalizes vue, @vue/* and vue-router when building.
Enabled by default.
export default defineNuxtConfig({
experimental: {
externalVue: true,
},
})
Tree shakes contents of client-only components from server bundle.
Enabled by default.
export default defineNuxtConfig({
experimental: {
treeshakeClientOnly: true,
},
})
Extracts handler functions from useAsyncData and useLazyAsyncData calls into separate chunks for improved code splitting and caching efficiency.
export default defineNuxtConfig({
experimental: {
extractAsyncDataHandlers: true,
},
})
This feature transforms inline handler functions into dynamically imported chunks:
<!-- Before -->
<script setup>
const { data } = await useAsyncData('user', async () => {
return await $fetch('/api/user')
})
</script>
<!-- After transformation -->
<script setup>
const { data } = await useAsyncData('user', () =>
import('/generated-chunk.js').then(r => r.default()),
)
</script>
The benefit of this transformation is that we can split out data fetching logic — while still allowing the code to be loaded if required.
Emits app:chunkError hook when there is an error loading vite/webpack chunks. Default behavior is to perform a reload of the new route on navigation to a new route when a chunk fails to load.
If you set this to 'automatic-immediate' Nuxt will reload the current route immediately, instead of waiting for a navigation. This is useful for chunk errors that are not triggered by navigation, e.g., when your Nuxt app fails to load a lazy component. A potential downside of this behavior is undesired reloads, e.g., when your app does not need the chunk that caused the error.
You can disable automatic handling by setting this to false, or handle chunk errors manually by setting it to manual.
export default defineNuxtConfig({
experimental: {
emitRouteChunkError: 'automatic', // or 'automatic-immediate', 'manual' or false
},
})
Allows Nuxt app state to be restored 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.
useState as auto-generated keys may not match across builds.export default defineNuxtConfig({
experimental: {
restoreState: true,
},
})
Define route rules at the page level using defineRouteRules.
export default defineNuxtConfig({
experimental: {
inlineRouteRules: true,
},
})
Matching route rules will be created, based on the page's path.
Allows rendering of JSON payloads with support for revivifying complex types.
Enabled by default.
export default defineNuxtConfig({
experimental: {
renderJsonPayloads: true,
},
})
Disables Vue server renderer endpoint within Nitro.
export default defineNuxtConfig({
experimental: {
noVueServer: true,
},
})
Enables extraction of payloads of pages generated with nuxt generate.
export default defineNuxtConfig({
experimental: {
payloadExtraction: true,
},
})
Enables the experimental <NuxtClientFallback> component for rendering content on the client if there's an error in SSR.
export default defineNuxtConfig({
experimental: {
clientFallback: true,
},
})
Enables cross-origin prefetch using the Speculation Rules API.
export default defineNuxtConfig({
experimental: {
crossOriginPrefetch: true,
},
})
Enables View Transition API integration with client-side router.
export default defineNuxtConfig({
experimental: {
viewTransition: true,
},
})
Enables writing of early hints when using node server.
export default defineNuxtConfig({
experimental: {
writeEarlyHints: true,
},
})
Enables experimental component islands support with <NuxtIsland> and .island.vue files.
export default defineNuxtConfig({
experimental: {
componentIslands: true, // false or 'local+remote'
},
})
Enables config schema support.
Enabled by default.
export default defineNuxtConfig({
experimental: {
configSchema: true,
},
})
Adds a compatibility layer for modules, plugins, or user code relying on the old @vueuse/head API.
export default defineNuxtConfig({
experimental: {
polyfillVueUseHead: false,
},
})
Allow disabling Nuxt SSR responses by setting the x-nuxt-no-ssr header.
export default defineNuxtConfig({
experimental: {
respectNoSSRHeader: false,
},
})
Resolve ~, ~~, @ and @@ aliases located within layers with respect to their layer source and root directories.
Enabled by default.
export default defineNuxtConfig({
experimental: {
localLayerAliases: true,
},
})
Enable the new experimental typed router using unplugin-vue-router.
export default defineNuxtConfig({
experimental: {
typedPages: true,
},
})
Out of the box, this will enable typed usage of navigateTo, <NuxtLink>, router.push() and more.
You can even get typed params within a page by using const route = useRoute('route-name').
pnpm without shamefully-hoist=true, you will need to have unplugin-vue-router installed as a devDependency in order for this feature to work.Set an alternative watcher that will be used as the watching service for Nuxt.
Nuxt uses chokidar-granular by default, which 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.
export default defineNuxtConfig({
experimental: {
watcher: 'chokidar-granular', // 'chokidar' or 'parcel' are also options
},
})
Enabling this feature automatically shares 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.
export default defineNuxtConfig({
experimental: {
sharedPrerenderData: true,
},
})
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.)
// 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}`)
})
With this feature, Nuxt will automatically polyfill Node.js imports in the client build using unenv.
Buffer work in the browser, you need to manually inject them.import { Buffer } from 'node:buffer'
globalThis.Buffer ||= Buffer
This option allows exposing some route metadata defined in definePageMeta at build-time to modules (specifically alias, name, path, redirect, props and middleware).
This only works with static or strings/arrays rather than variables or conditional assignment. See original issue for more information and context.
It is also possible to scan page metadata only after all routes have been registered in pages:extend. Then another hook, pages:resolved will be called. To enable this behavior, set scanPageMeta: 'after-resolve'.
You can disable this feature if it causes issues in your project.
export default defineNuxtConfig({
experimental: {
scanPageMeta: false,
},
})
Enables CookieStore support to listen for cookie updates (if supported by the browser) and refresh useCookie ref values.
export default defineNuxtConfig({
experimental: {
cookieStore: true,
},
})
Caches Nuxt build artifacts based on a hash of the configuration and source files.
export default defineNuxtConfig({
experimental: {
buildCache: true,
},
})
When enabled, changes to the following files will trigger a full rebuild:
.nuxtrc
.npmrc
package.json
package-lock.json
yarn.lock
pnpm-lock.yaml
tsconfig.json
bun.lock
bun.lockb
In addition, any changes to files within srcDir will trigger a rebuild of the Vue client/server bundle. Nitro will always be rebuilt (though work is in progress to allow Nitro to announce its cacheable artifacts and their hashes).
The definePageMeta() macro is a useful way to collect build-time meta about pages. Nuxt itself provides a set list of supported keys which is used to power some of the internal features such as redirects, page aliases and custom paths.
This option allows passing additional keys to extract from the page metadata when using scanPageMeta.
<script lang="ts" setup>
definePageMeta({
foo: 'bar',
})
</script>
export default defineNuxtConfig({
experimental: {
extraPageMetaExtractionKeys: ['foo'],
},
hooks: {
'pages:resolved' (ctx) {
// ✅ foo is available
},
},
})
This allows modules to access additional metadata from the page metadata in the build context. If you are using this within a module, it's recommended also to augment the NuxtPage types with your keys.
Ensure that auto-generated Vue component names match the full component name you would use to auto-import the component.
export default defineNuxtConfig({
experimental: {
normalizeComponentNames: true,
},
})
By default, if you haven't set it manually, Vue will assign a component name that matches the filename of the component.
├─ components/
├─── SomeFolder/
├───── MyComponent.vue
In this case, the component name would be MyComponent, as far as Vue is concerned. If you wanted to use <KeepAlive> with it, or identify it in the Vue DevTools, you would need to use this component.
But in order to auto-import it, you would need to use SomeFolderMyComponent.
By setting experimental.normalizeComponentNames, these two values match, and Vue will generate a component name that matches the Nuxt pattern for component naming.
When rendering a client-only page (with ssr: false), we optionally render a loading screen (from app/spa-loading-template.html).
It can be set to within, which will render it like this:
<div id="__nuxt">
<!-- spa loading template -->
</div>
Alternatively, you can render the template alongside the Nuxt app root by setting it to body:
<div id="__nuxt"></div>
<!-- spa loading template -->
This avoids a white flash when hydrating a client-only page.
Enables performance markers for Nuxt hooks in browser devtools. This adds performance markers that you can track in the Performance tab of Chromium-based browsers, which is useful for debugging and optimizing performance.
This is enabled by default in development mode. If you need to disable this feature, it is possible to do so:
export default defineNuxtConfig({
experimental: {
browserDevtoolsTiming: false,
},
})
Records mutations to nuxt.options in module context, helping to debug configuration changes made by modules during the Nuxt initialization phase.
This is enabled by default when debug mode is enabled. If you need to disable this feature, it is possible to do so:
To enable it explicitly:
export default defineNuxtConfig({
experimental: {
debugModuleMutation: true,
},
})
This enables hydration strategies for <Lazy> components, which improves performance by deferring hydration of components until they're needed.
Lazy hydration is enabled by default, but you can disable this feature:
export default defineNuxtConfig({
experimental: {
lazyHydration: false,
},
})
Controls how imports in Nuxt templates are resolved. By default, Nuxt attempts to resolve imports in templates relative to the module that added them.
This is enabled by default, so if you're experiencing resolution conflicts in certain environments, you can disable this behavior:
export default defineNuxtConfig({
experimental: {
templateImportResolution: false,
},
})
This option enables enabling decorator syntax across your entire Nuxt/Nitro app, powered by esbuild.
For a long time, TypeScript has had support for decorators via compilerOptions.experimentalDecorators. This implementation predated the TC39 standardization process. Now, decorators are a Stage 3 Proposal, and supported without special configuration in TS 5.0+ (see https://github.com/microsoft/TypeScript/pull/52582 and https://devblogs.microsoft.com/typescript/announcing-typescript-5-0-beta/#decorators).
Enabling experimental.decorators enables support for the TC39 proposal, NOT for TypeScript's previous compilerOptions.experimentalDecorators implementation.
export default defineNuxtConfig({
experimental: {
decorators: true,
},
})
function something (_method: () => unknown) {
return () => 'decorated'
}
class SomeClass {
@something
public someMethod () {
return 'initial'
}
}
const value = new SomeClass().someMethod()
// this will return 'decorated'
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:
export default defineNuxtConfig({
experimental: {
purgeCachedData: false,
},
})
Whether to call and use the result from getCachedData when refreshing data for useAsyncData and useFetch (whether by watch, refreshNuxtData(), or a manual refresh() call.
export default defineNuxtConfig({
experimental: {
granularCachedData: true,
},
})
If set to false, the pending object returned from useAsyncData, useFetch, useLazyAsyncData and useLazyFetch will be a computed property that is true only when status is also pending.
That means that when immediate: false is passed, pending will be false until the first request is made.
export default defineNuxtConfig({
experimental: {
pendingWhenIdle: false,
},
})
By default, Nuxt improves chunk stability by using an import map to resolve the entry chunk of the bundle.
This injects an import map at the top of your <head> tag:
<script type="importmap">{"imports":{"#entry":"/_nuxt/DC5HVSK5.js"}}</script>
Within the script chunks emitted by Vite, imports will be from #entry. This means that changes to the entry will not invalidate chunks which are otherwise unchanged.
vite.build.target to include a browser that doesn't support import maps, or if you have configured vite.build.rollupOptions.output.entryFileNames to a value that does not include [hash].If you need to disable this feature you can do so:
export default defineNuxtConfig({
experimental: {
entryImportMap: false,
},
// or, better, simply tell vite your desired target
// which nuxt will respect
vite: {
build: {
target: 'safari13',
},
},
})
Enable enhanced TypeScript developer experience with the @dxup/nuxt module.
This experimental plugin provides improved TypeScript integration and development tooling for better DX when working with TypeScript in Nuxt applications.
This flag is disabled by default, but you can enable this feature:
export default defineNuxtConfig({
experimental: {
typescriptPlugin: true,
},
})
typescript installed as a dependencyEnable Vite 6's new Environment API for improved build configuration and plugin architecture.
When you set future.compatibilityVersion to 5, this feature is enabled by default. You can also enable it explicitly for testing:
export default defineNuxtConfig({
experimental: {
viteEnvironmentApi: true,
},
})
The Vite Environment API provides better consistency between development and production builds, more granular control over environment-specific configuration, and improved performance.