Additional changes to review1 matched termMatched wording:removedThese matches may be harmless in context. Expand to see the excerpts.
- The changelog contains “removed”; check what was removed.
Removed unused composable example (#26283)
Nuxt is a free and open-source framework with an intuitive and extendable way to create type-safe, performant and production-grade full-stack web applications and websites with Vue.js.
Last checked
Checking sources…
Removed unused composable example (#26283)
We've also added a dev:ssr-logs hook (both in Nuxt and Nitro) which is called on server and client, allowing you to handle them yourself if you want to.
If you encounter any issues with this, it is possible to disable them - or prevent them from logging to your browser console.
export default defineNuxtConfig({
features: {
devLogs: false
// or 'silent' to allow you to handle yourself with `dev:ssr-logs` hook
},
})
A new usePreviewMode composable aims to make it simple to use preview mode in your Nuxt app.
const { enabled, state } = usePreviewMode()
When preview mode is enabled, all your data fetching composables, like useAsyncData and useFetch will rerun, meaning any cached data in the payload will be bypassed.
We now automatically cache-bust your payloads if you haven't disabled Nuxt's app manifest, meaning you shouldn't be stuck with outdated data after a deployment.
routeRulesIt's now possible to define middleware for page paths within the Vue app part of your application (that is, not your Nitro routes) (#25841).
export default defineNuxtConfig({
routeRules: {
'/admin/**': {
// or appMiddleware: 'auth'
appMiddleware: ['auth']
},
'/admin/login': {
// You can 'turn off' middleware that would otherwise run for a page
appMiddleware: {
auth: false
}
},
},
})
clear data fetching utilityNow, useAsyncData and useFetch expose a clear utility. This is a function that can be used to set data to undefined, set error to null, set pending to false, set status to idle, and mark any currently pending requests as cancelled. (#26259)
<script setup lang="ts">
const { data, clear } = await useFetch('/api/test')
const route = useRoute()
watch(() => route.path, (path) => {
if (path === '/') clear()
})
</script>
#teleports targetNuxt now includes a new <div id="teleports"></div> element in your app within your <body> tag. It supports server-side teleports, meaning you can do this safely on the server:
<template>
<Teleport to="#teleports">
<span>
Something
</span>
</Teleport>
</template>
It's now possible to set custom timings for hiding the loading indicator, and forcing the finish() method if needed (#25932).
There's also a new page:view-transition:start hook for hooking into the View Transitions API (#26045) if you have that feature enabled.
This release sees server- and client-only pages land in Nuxt! You can now add a .server.vue or .client.vue suffix to a page to get automatic handling of it.
Client-only pages will render entirely on the client-side, and skip server-rendering entirely, just as if the entire page was wrapped in <ClientOnly>. Use this responsibly. The flash of load on the client-side can be a bad user experience so make sure you really need to avoid server-side loading. Also consider using <ClientOnly> with a fallback slot to render a skeleton loader (#25037).
⚗️ Server-only pages are even more useful because they enable you to integrate fully-server rendered HTML within client-side navigation. They will even be prefetched when links to them are in the viewport - so you will get instantaneous loading (#24954).
When you are using server components, you can now use the nuxt-client attribute anywhere within your tree (#25479).
export default defineNuxtConfig({
experimental: {
componentIslands: {
selectiveClient: 'deep'
}
},
})
You can listen to an @error event from server components that will be triggered if there is any issue loading the component (#25798).
Finally, server-only components are now smartly enabled when you have a server-only component or a server-only page within your project or any of its layers (#26223).
Server components remain experimental and their API may change, so be careful before depending on implementation details.
We've shipped a number of performance improvements, including only updating changed virtual templates (#26250), using a 'layered' prerender cache (#26104) that falls back to filesystem instead of keeping everything in memory when prerendering - and lots of other examples.
We have shipped a reimplementation of Vite's public asset handling, meaning that public assets in your public/ directory or your layer directories are now resolved entirely by Nuxt (#26163), so if you have added nitro.publicAssets directories with a custom prefix, these will now work.
We have changed the default _nuxt/[name].[hash].js file name pattern for your JS chunks. Now, we default to _nuxt/[hash].js. This is to avoid false positives by ad blockers triggering off your component or chunk names, which can be a very difficult issue to debug. (#26203)
You can easily configure this to revert to previous behaviour if you wish:
export default defineNuxtConfig({
vite: {
$client: {
build: {
rollupOptions: {
output: {
chunkFileNames: '_nuxt/[name].[hash].js',
entryFileNames: '_nuxt/[name].[hash].js'
}
}
}
}
},
})
Previously users with shamefully-hoist=false may have encountered issues with types not being resolved or working correctly. You may also have encountered problems with excessive type instantiation.
We now try to tell TypeScript about certain key types so they can be resolved even if deeply nested (#26158).
There are a whole raft of other type fixes, including some regarding import types (#26218 and #25965) and module typings (#25548).
As usual, our recommendation for upgrading is to run:
nuxi upgrade --force
This will refresh your lockfile as well, and ensures that you pull in updates from other dependencies that Nuxt relies on, particularly in the unjs ecosystem.
nuxt-client in all components (#25479)page:view-transition:start hook (#26045)finish() (#25932)<NuxtIsland> can't fetch island (#25798)usePreviewMode composable (#21705)#teleports element for ssr teleports (#25043)typescript.hoist (85166cced)getCachedData (#26287)nuxtMiddleware route rule (#25841)clear utility to useAsyncData/useFetch (#26259)isPrerendered in dev for server page (#26061).config/nuxt.config (5440ecece).config/nuxt.* (7815aa534)error in showError/createError with h3 (#25945)useId (#25969)vueCompilerOptions property to tsConfig (#25924)useRuntimeConfig in Nuxt renderer (#26058)typescript.shim in favour of volar (#26052)defu/h3 paths in type templates (#26085)toExports from unimport (#26086)AsyncDataRequestStatus type (#26023)<html> and <body> attrs (#26027)node_modules for modulesDir (#25548)routeRules (#26120)cookieRef values deeply (#26151)ssrRender (#26162)ssr: false (f080c426a)baseUrl within server components (#25727)useNuxtData (#22277)publicAssetsURL (9d08cdfd1)buildAssetsDir (81933dfc3)joinRelativeURL for build assets (#26282)deep to selectiveClient (357f8db41)consola for now (adbd53a25)window access more carefully (977377777)useId composable was introduced (#25953)domEnvironment option to testing example (#25972)fallback prop for <NuxtLayout> (#26091)vue-tsc (#26083)macros.pageMeta and typescript.esbuild option (#26136)definePageMeta page (#26139)app:manifest:update hook (#26192)zhead (e889a7df5)clear (24217a992)appMiddleware docs (da8e8eba8)scrollY (#26298)networkidle (9b5bffbbb)