Skip to content

Commit

Permalink
docs: add docs for future.compatibilityVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed May 1, 2024
1 parent f597ca5 commit e7789a2
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
32 changes: 32 additions & 0 deletions docs/2.guide/3.going-further/1.features.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 37,38 @@ export default defineNuxtConfig({

There is also a `future` namespace for early opting-in to new features that will become default in a future (possibly major) version of the framework.

### compatibilityVersion

::important
This configuration option is available in Nuxt v3.12 .
::

This enables early access to Nuxt features or flags.

Setting `compatibilityVersion` to `4` changes defaults throughout your
Nuxt configuration to opt-in to Nuxt v4 behaviour, 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.

```ts
export default defineNuxtConfig({
future: {
compatibilityVersion: 4,
},
// To re-enable _all_ Nuxt v3 behaviour, set the following options:
experimental: {
compileTemplate: true,
templateUtils: true,
relativeWatchPaths: true,
defaults: {
useAsyncData: {
deep: true
}
}
}
})
```

### typescriptBundlerResolution

This enables 'Bundler' module resolution mode for TypeScript, which is the recommended setting
Expand Down
27 changes: 26 additions & 1 deletion packages/schema/src/config/experimental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 8,31 @@ export default defineUntypedSchema({
future: {
/**
* Enable 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.
*
* @example
* ```ts
* export default defineNuxtConfig({
* future: {
* compatibilityVersion: 4,
* },
* // To re-enable _all_ Nuxt v3 behaviour, set the following options:
* experimental: {
* compileTemplate: true,
* templateUtils: true,
* relativeWatchPaths: true,
* defaults: {
* useAsyncData: {
* deep: true
* }
* }
* }
* })
* ```
* @type {3 | 4}
*/
compatibilityVersion: 3,
Expand Down Expand Up @@ -265,7 290,7 @@ export default defineUntypedSchema({
* - Uses the hash hydration plugin to reduce initial hydration
* @see [Nuxt Discussion #22632](https://github.com/nuxt/nuxt/discussions/22632]
*/
headNext: false,
headNext: true,

/**
* Allow defining `routeRules` directly within your `~/pages` directory using `defineRouteRules`.
Expand Down

0 comments on commit e7789a2

Please sign in to comment.