Nuxt 3.8
๐ป CLI Improvements
Just to remind you, we're now using the new Nuxt CLI which is now versioned separately.
nuxi module add <module-name>
โจ Built-in Nuxt DevTools
Nuxt DevTools v1.0.0 is out and we now think it's ready to be shipped as a direct dependency of Nuxt.
๐ธ Nuxt Image Auto-install
<NuxtImg>
and <NuxtPicture>
first-class built-in components.
We now auto-installing @nuxt/image
the first time that they are used (#23717).
@nuxt/image
if you're using images in your site; it can apply optimisations to make your site more performant.๐ Deeper Layout Scanning
We now support scanning layouts within subfolders in ~/layouts
in the same way as we do with ~/components
.
File | Layout name |
---|---|
~/layouts/desktop/default.vue | 'desktop-default' |
~/layouts/desktop-base/base.vue | 'desktop-base' |
~/layouts/desktop/index.vue | 'desktop' |
๐ App Manifest
We now support a built-in app manifest (see PR #21641), which generates a manifest at /_nuxt/builds/meta/<buildId>.json
.
It enables loading payloads only for prerendered routes, if a site is generated with nuxt generate
, preventing 404s in the console.
It also enables client-side route rules. Only redirect
route rules is supported for now; they will now redirect when performing client-side navigation.
export default defineNuxtConfig({
routeRules: {
'/about': { redirect: '/about-us' }
}
})
/_nuxt/builds/latest.json
.experimental.appManifest
to false
in your nuxt.config
file.๐ค Scope and Context Improvements
We now define a 'scope' for Nuxt composables executed in plugins (#23667), which allows running synchronous cleanup before navigating away from your site, using the Vue onScopeDispose
lifecycle method.
We also now support native async context for the Vue composition API (#23526). In case you're unaware, we support native async context on Node and Bun, enabled with experimental.asyncContext
.
If you experience issues with Nuxt instance unavailable
, enabling this option may solve your issues:
export default defineNuxtConfig({
experimental: {
asyncContext: true
}
})
๐ NuxtLink Defaults
You can define your own <NuxtLink>
components with the defineNuxtLink
utility.
Today, you can cutomize the options for the built-in <NuxtLink>
, directly in your nuxt.config
file (#23724).
This can enable you to enforce trailing slash behaviour across your entire site, for example:
export default defineNuxtConfig({
experimental: {
defaults: {
nuxtLink: {
activeClass: 'nuxt-link-active',
trailingSlash: 'append'
}
}
}
})
โก๏ธ Data Fetching Improvements
We have two very significant new features for useAsyncData
and useFetch
:
- You can now set
deep: false
to prevent deep reactivity on thedata
object returned from these composables (#23600). It should be a performance improvement if you are returning large arrays or objects. The object will still update when refetched; it just won't trigger reactive effects if you change a property deep within thedata
. - You can now use the
getCachedData
option to handle custom caching for these composables (#20747)
<script setup>
const nuxtApp = useNuxtApp()
const { data } = await useAsyncData(() => { /* fetcher */ }, {
// this will not refetch if the key exists in the payload
getCachedData: key => nuxtApp.payload.static[key] ?? nuxtApp.payload.data[key]
})
</script>
We also support configuring some default values for these composables in an app-wide way (#23725):
export default defineNuxtConfig({
experimental: {
defaults: {
useAsyncData: {
deep: false
},
useFetch: {
retry: false,
retryDelay: 100,
retryStatusCodes: [500],
timeout: 100
}
}
}
})
๐ข Layer Improvements
We now more carefully load layer plugins (#22889 and #23148) and middleware (#22925 and #23552) in the order of the layers, always loading your own plugins and middleware last. This should mean you can rely on utilities that layers may inject.
And probably one of the most significant changes - if you are using remote layers we now clone these within your node_modules/
folder (#109) so layers can use dependencies with your project. See c12
release notes for full details.
๐ด Nightly Release Channel
Every commit to the main
branch of Nuxt is automatically deployed to a new release, for easier testing before releases. We've renamed this from the 'edge release channel' to the 'nightly release channel' to avoid confusion with edge deployments. And probably also with Microsoft Edge (though I haven't heard that anyone was confused with that one!)
nuxt3
is nownuxt-nightly
nuxi-edge
is nownuxi-nightly
@โnuxt/kit-edge
is now@โnuxt/kit-nightly
- ... and so on.
โ๏ธ Nitro v2.7
Nitro v2.7 has been released with lots of improvements and bug fixes.
fetch
supported in Node 18+ (#1724). So if possible, we'd recommend you update your Node version to at least 18.๐ช Type Import Changes
Vue requires that type imports be explicit (so that the Vue compiler can correctly optimise and resolve type imports for props and so on). See core Vue tsconfig.json
.
We've therefore taken the decision to turn on verbatimModuleSyntax
by default in Nuxt projects, which will throw a type error if types are imported without an explicit type
import. To resolve it you will need to update your imports:
- import { someFunction, SomeOptions } from 'some-library'
+ import { someFunction } from 'some-library'
+ import type { SomeOptions } from 'some-library'
You may also encounter modules in the Nuxt ecosystem that need to be updated; please open an issue for those modules. I'm also very happy to help if you're encountering any problems with this, if you're a module author. Just tag me and I'll take a look.
If for whatever reason you need to undo this change in your project you can set the following configuration:
export default defineNuxtConfig({
typescript: {
tsConfig: {
compilerOptions: {
verbatimModuleSyntax: false
}
}
}
})
However, we'd recommend only doing that temporarily, as Vue does need this option to be set for best results.
โ
Upgrading
As usual, our recommendation for upgrading is to run:
npx nuxi upgrade
Full Release Notes
Thank you for reading this far! We hope you enjoy the new release. Please do let us know if you have any feedback or issues.
Happy Nuxting โจ