Tech January 25, 2026 约 10 分钟阅读

Deep Dive into Nuxt 4 New Features

Nuxt 4.0 has been officially released, marking a significant milestone focused on stability, performance, and improved developer experience. This major release introduces several key changes in project structure, data fetching, and TypeScript integration. Let's explore the core features of Nuxt 4.

1. New Project Structure: The app/ Directory

The most visible change in Nuxt 4 is the introduction of the app/ directory as the default location for your application code.

Why this change?

  • Separation of Concerns: Application code (pages, components, layouts, etc.) is now clearly separated from root-level configuration files and build artifacts.
  • Improved Performance: The file watcher now only needs to monitor the app/ directory, leading to faster response times in development.
  • Better IDE Support: IDEs can now provide more accurate context-aware completions by knowing exactly where the application logic resides.

Note: This change is backward compatible. Existing projects using the root directory for app files will continue to work.

2. Smarter Data Fetching

Data fetching utilities like useFetch and useAsyncData have been significantly enhanced in Nuxt 4.

  • Automatic Data Sharing: If multiple components request data with the same key, Nuxt 4 automatically shares the request and response, preventing duplicate network calls.
  • Automatic Cleanup: Data is automatically cleared from the state when the component is unmounted, helping to prevent memory leaks.
  • Reactive Keys: Keys are now more flexible and can be reactive, automatically re-triggering fetches when their values change.

3. Enhanced TypeScript Support

Nuxt 4 takes TypeScript integration to the next level with a layered approach:

  • Separate TS Projects: The application code, server code (server/), and shared code (shared/) now have their own independent TypeScript configurations.
  • Accurate Type Inference: This separation reduces type conflicts between client-side and server-side code.
  • Improved Autocomplete: Typing for Nitro routes, components, and composables is now more precise and faster.

4. Performance and Tooling

  • Internal Sockets: Communication between the CLI and the development server now uses internal sockets, resulting in faster startup times and snappier HMR.
  • Vite 6 Compatibility: Nuxt 4 is built to leverage the latest improvements in Vite, including better build performance and modern ESM support.
  • Nitro 3 Readiness: The runtime is optimized for the upcoming Nitro 3 release, promising an even smaller and faster production bundle.

5. Improvements in Nuxt 4.1

The Nuxt 4.1 release brought even more refinements:

  • Chunk Stability: Improved import maps help prevent cascading cache invalidations when a single file changes.
  • Experimental Rolldown Support: Initial support for the Rust-based Rolldown bundler, paving the way for significantly faster build times in the future.

Conclusion

Nuxt 4 is more than just a version bump; it's a step towards a more mature and efficient full-stack framework. Whether you're starting a new project or upgrading an existing one, these features provide a solid foundation for modern web development.


Published on: January 25, 2025Last updated: January 25, 2025