|
| 1 | +--- |
| 2 | +title: Nuxt 3.18 |
| 3 | +description: Nuxt 3.18 is out - bringing v4 features to v3, improved accessibility, better browser dev tooling integration, and performance enhancements! |
| 4 | +navigation: false |
| 5 | +image: /assets/blog/v3.18.png |
| 6 | +authors: |
| 7 | + - name: Daniel Roe |
| 8 | + avatar: |
| 9 | + src: https://github.com/danielroe.png |
| 10 | + to: https://bsky.app/profile/danielroe.dev |
| 11 | +date: 2025-07-28T10:00:00.000Z |
| 12 | +category: Release |
| 13 | +--- |
| 14 | + |
| 15 | +## 🧪 Lazy Hydration Macros |
| 16 | + |
| 17 | +Building on the delayed hydration support from v3.16, we now support **lazy hydration macros** ([#31192](https://github.com/nuxt/nuxt/pull/31192))! These provide a more ergonomic way to control component hydration: |
| 18 | + |
| 19 | + |
| 20 | +```vue |
| 21 | +<script setup lang="ts"> |
| 22 | +const LazyHydrationMyComponent = defineLazyHydrationComponent( |
| 23 | + 'visible', |
| 24 | + () => import('./components/MyComponent.vue') |
| 25 | +) |
| 26 | +</script> |
| 27 | +<template> |
| 28 | + <div> |
| 29 | + <!-- |
| 30 | + Hydration will be triggered when |
| 31 | + the element(s) is 100px away from entering the viewport. |
| 32 | + --> |
| 33 | + <LazyHydrationMyComponent :hydrate-on-visible="{ rootMargin: '100px' }" /> |
| 34 | + </div> |
| 35 | +</template> |
| 36 | +``` |
| 37 | + |
| 38 | +These macros make it possible to use Nuxt's lazy hydration utilities alongside explicit component imports. |
| 39 | + |
| 40 | +## ♿️ Accessibility Improvements |
| 41 | + |
| 42 | +We've enhanced accessibility by including `<NuxtRouteAnnouncer>` in the built-in `app.vue` ([#32621](https://github.com/nuxt/nuxt/pull/32621)). This means page changes will be announced to screen readers, making navigation more accessible for users with visual impairments. (This only applies if you do not have an `app.vue` in your project. If you do, please keep `<NuxtRouteAnnouncer>` in your `app.vue`!) |
| 43 | + |
| 44 | +## 🛠️ Enhanced Development Experience |
| 45 | + |
| 46 | +### Chrome DevTools Workspace Integration |
| 47 | + |
| 48 | +We've added **Chrome DevTools workspace integration** ([#32084](https://github.com/nuxt/nuxt/pull/32084)), allowing you to edit your Nuxt source files directly from Chrome DevTools. This creates a better debugging experience where changes made in DevTools are reflected in your actual source files. |
| 49 | + |
| 50 | +### Better Component Type Safety |
| 51 | + |
| 52 | +Component type safety has been improved with: |
| 53 | + |
| 54 | +- **Typed slots for `<ClientOnly>` and `<DevOnly>`** ([#32707](https://github.com/nuxt/nuxt/pull/32707)) - better IntelliSense and error checking |
| 55 | +- **Exported `<NuxtTime>` prop types** ([#32547](https://github.com/nuxt/nuxt/pull/32547)) - easier to extend and customize |
| 56 | + |
| 57 | +### New Auto-Import: `onWatcherCleanup` |
| 58 | + |
| 59 | +The `onWatcherCleanup` function from `vue` is now available as an auto-import ([#32396](https://github.com/nuxt/nuxt/pull/32396)), making it easier to clean up watchers and prevent memory leaks: |
| 60 | + |
| 61 | +```ts |
| 62 | +const { data } = useAsyncData('users', fetchUsers) |
| 63 | + |
| 64 | +watch(data, (newData) => { |
| 65 | + const interval = setInterval(() => { |
| 66 | + // Some periodic task |
| 67 | + }, 1000) |
| 68 | + |
| 69 | + // Clean up when the watcher is stopped |
| 70 | + onWatcherCleanup(() => { |
| 71 | + clearInterval(interval) |
| 72 | + }) |
| 73 | +}) |
| 74 | +``` |
| 75 | + |
| 76 | +## 📊 Observability Enhancements |
| 77 | + |
| 78 | +Page routes are now **exposed to Nitro for observability** ([#32617](https://github.com/nuxt/nuxt/pull/32617)), enabling better monitoring and analytics integration with supported platforms. This allows observability tools to track page-level metrics more effectively. |
| 79 | + |
| 80 | +## 🔧 Module Development Improvements |
| 81 | + |
| 82 | +Module authors get several quality-of-life improvements: |
| 83 | + |
| 84 | +### Simplified Server Imports |
| 85 | + |
| 86 | +The `addServerImports` kit utility now **supports single imports** ([#32289](https://github.com/nuxt/nuxt/pull/32289)), making it easier to add individual server utilities: |
| 87 | + |
| 88 | +```ts |
| 89 | +// Before: had to wrap in array |
| 90 | +addServerImports([{ from: 'my-package', name: 'myUtility' }]) |
| 91 | + |
| 92 | +// Now: can pass directly |
| 93 | +addServerImports({ from: 'my-package', name: 'myUtility' }) |
| 94 | +``` |
| 95 | + |
| 96 | +### TypeScript Configuration |
| 97 | + |
| 98 | +Modules can now **add to `typescript.hoist`** ([#32601](https://github.com/nuxt/nuxt/pull/32601)), giving them more control over TypeScript configuration and type generation. |
| 99 | + |
| 100 | +## ⚡️ Performance Improvements |
| 101 | + |
| 102 | +We've made several performance optimizations: |
| 103 | + |
| 104 | +- **Improved Vite-node communication** via internal socket ([#32417](https://github.com/nuxt/nuxt/pull/32417)) for faster development builds |
| 105 | +- **Migration to `oxc-walker`** ([#32250](https://github.com/nuxt/nuxt/pull/32250)) and **oxc for `onPrehydrate` transforms** ([#32045](https://github.com/nuxt/nuxt/pull/32045)) for faster code transformations |
| 106 | + |
| 107 | +## 🐛 Bug Fixes |
| 108 | + |
| 109 | +This release also includes several important fixes: |
| 110 | + |
| 111 | +- **Improved data fetching**: When computed keys change, old data is now properly retained ([#32616](https://github.com/nuxt/nuxt/pull/32616)) |
| 112 | +- **Better scroll behavior**: `scrollBehaviorType` is now only used for hash scrolling ([#32622](https://github.com/nuxt/nuxt/pull/32622)) |
| 113 | +- **Fixed directory aliases**: Added trailing slashes to some directory aliases for better consistency ([#32755](https://github.com/nuxt/nuxt/pull/32755)) |
| 114 | + |
| 115 | +## ✅ Upgrading |
| 116 | + |
| 117 | +As usual, our recommendation for upgrading is to run: |
| 118 | + |
| 119 | +```sh |
| 120 | +npx nuxi@latest upgrade --dedupe |
| 121 | +``` |
| 122 | + |
| 123 | +This refreshes your lockfile and pulls in all the latest dependencies that Nuxt relies on, especially from the unjs ecosystem. |
| 124 | + |
| 125 | +## Full release notes |
| 126 | + |
| 127 | +::read-more |
| 128 | +--- |
| 129 | +icon: i-simple-icons-github |
| 130 | +target: _blank |
| 131 | +to: https://github.com/nuxt/nuxt/releases/tag/v3.18.0 |
| 132 | +--- |
| 133 | +Read the full release notes of Nuxt `v3.18.0`. |
| 134 | +:: |
| 135 | + |
| 136 | +A huge thank you to everyone who's been a part of this release. Over the next six months, we'll continue backporting compatible v4 features and bug fixes, so please keep the feedback coming! ❤️ |
0 commit comments