Guides

Exploring Nuxt3: the hybrid Vue framework

David Adeneye

David is a developer & technical writer. When he is not writing code/content, he is reading on how to design and develop good software products.

Published on

May 18, 2022
Exploring Nuxt3: the hybrid Vue framework

After Vue 3 stable release, the Nuxt team recently launched Nuxt 3. Nuxt 3 is a Hybrid Vue framework that enables you to build applications with Vue 3. It provides many outstanding features like hybrid rendering, powerful data fetching, Composition API, etc. Nuxt 3's public beta was released in October. Since then, it has garnered much interest among the Nuxt community for its features that enable developers to create great user experiences seamlessly.

Nuxt mission is to provide a great developer experience while making web development robust and performant. This article will explore all the new unique features of Nuxt3 and its installation process.

What is Nuxt 3

Nuxt 3 is an updated version of Nuxt 2 redesigned to make web development more powerful and simple. It is an open-source hybrid vue framework that enables us to build performant web applications with Vue 3. The Nuxt framework is written in typescript for built-in typescript support and easy maintainability. In addition, it provides us with many exceptional features and developer experience improvements described in this article.

Nuxt mission is to make it easy for developers to build applications without worrying about the configuration or building systems from scratch in JavaScript. Instead, it takes care of all the finer details so you can focus on what matters while building your web applications. It has gained a high level of popularity because of its simplicity and powerful features. It allows you to spend less time worrying about your app's architecture and more time creating great experiences for your users.

Nuxt 3 was developed with the modern web in mind. As a result, it's equipped with features that will take your projects forward. Here are some reasons why Nuxt 3 is an excellent framework.

  • Improved Performance: The performance of Nuxt is excellent. It has a high speed and covers the majority by default from lazy-loading, prefetch, and preload.
  • Nuxt Bridge: Nuxt Bridge lets you switch from Nuxt 2 to Nuxt 3. It makes migration seamless and enables you to upgrade to Nuxt 3 improvements on performance and features.
  • Enhanced Developer Experiences: Developers will see more improvements in Nuxt 3, such as the auto-import of global utilities and composable functions, the Nuxt CLI for scaffolding projects and module integration, a faster and easier debugging in the browser with Nuxt Devtools, and a Nuxt Kit for modern utility modules toolkit.

Features of Nuxt 3

The public beta of Nuxt 3 brought about many improvements to the framework. Let's take a look at them below:

General Optimization

Nuxt 3 provides a wide range of improvements and general improvements. As a result, the bundles are smaller, and the core is 20% lighter than Nuxt2 with improved performance. In addition, thanks to the new Nitro server engine, developers can expect better performance in development through improved cold starts and dynamic code splitting.

Also, various tooling parts have been upgraded, such as Webpack 5, ESbuild and PostCSS 8, Vite support, etc. These upgrades make both development and production build extremely fast.

TypeScript

The Nuxt 3 project is written in TypeScript for built-in support of TypeScript and easier maintenance. Nuxt 3 adopts TypeScript and ES modules as first-class citizens to enhance development experiences. The integration of tight TypeScript in Nuxt 3 will help provide type-checking for the codebase and error detection and auto-completion even without the use of TypeScript.

However, if you don't integrate TypeScript into your project, you will still be able to use Nuxt without any problems.

Vue 3

Just as Nuxt 2 relies on Vue 2, Nuxt 3 depends on Vue 3. Therefore, it will help provide an experience tailored to the latest version of Vue 3. Thus, we can incorporate features like enhanced module import, composition API, and Improved overall app performance.

Nitro Engine

The Nitro Engine is Nuxt 3's new server engine, one of the headline features. This engine will enable several additional capabilities and some new features. Among the benefits of a Nitro Engine are Serverless support out-of-the-box, Dynamic server code-splitting, Hybrid rendering, a Development server with hot reloading, etc.

Nuxt Bridge

Because Nuxt 3 relies on Vue 3, there is a compatibility problem when upgrading from Nuxt 2 to Nuxt 3. In addition, vue 3 has made many tools and libraries obsolete from the Vue 2 ecosystem. Thus, Nuxt Bridge is an implementation designed to make upgrading to Nuxt 3 seamless.

Nuxt bridge is a forward-compatibility layer that helps us bring Nuxt 3 features to Nuxt 2. By installing and activating Nuxt 3 modules, you can access many Nuxt 3's features. Here are some of the new features:

  • Dev tools
  • Vite Integration
  • Nuxt CLI
  • Built-in TypeScript and ES module support
  • Nitro Engine
  • Composition API with Nuxt 3 composable and auto imports

To learn more about the Nuxt bridge, check here.

Hybrid Rendering

With Nuxt 3, you can get hybrid rendering or so-called "incremental static generation." As a result, you will have access to features such as incremental static generation - a combination of SSG and SSR. Using this feature, you can decide whether and how long you want your pages to be rendered statically or dynamically. The beta release will include more details on this feature.

New File Structure

The pages/directory in Nuxt 3 is optional, while the app.vue file is the primary element of our Nuxt 3 application. The app.vue is the core component of your Nuxt application; whatever you add to it (JS and CSS) will be included on every page. The approach is useful when working on a one-page application, such as a landing page or an application that does not require routing.

Cross-Platform Support

As JavaScript has evolved rapidly over the last few years, several JS-powered platforms have emerged - and Nuxt 3 supports them all. In addition, Nuxt 3 runs seamlessly on all JS environments due to the improved dependency tracking and new lightweight polyfills described previously. This includes Deno, Cloudflare Workers, Node.js, etc.

API Routes

Through Nitro, developers will be able to create and run server API code efficiently, as they can currently do with many other full-stack frameworks. The new server API will be located in the server/api directory, while server functions reside in server/functions/. New API routes, improved serverless support, and new isomorphic fetching mechanisms are positive steps forward.

How to Setup a new Project in Nuxt 3

Please note that Nuxt 3 is still in beta and only supports Node 14 or 16. Open your terminal and run the following command to create a new starter project to start a new project.

npx nuxi init nuxt-app

After that, you will need to install the dependencies in the package.json file. Go into the project directory and install the dependencies:

cd nuxt-app
npm install

OR

yarn install

Once you complete these steps, you can start your application:

npm run dev

OR

yarn dev

If it works successfully, a browser window will automatically open at http://localhost:300. and your output should look like this below.

Nuxt3 demo

Nuxt 3 offers plugins that extend the capabilities of your application via the JavaScript library. You can extend the functionality of your Nuxt application in three different ways:

  • By utilizing external Javascript packages and modules in Nuxt 3
  • By using your favorite Vue.js plugins in the Nuxt 3 application
  • By making functions to be available on the client-side and server-side

You can learn more about plugins here.

Conclusion

We hope you're excited about Nuxt 3 new features and possibilities, as we can't wait to use them in production. In this post, we explored some of the numerous features of Nuxt 3 and how to set up a new project.

The Nuxt 3 release will enable Vue developers to upgrade to Vue 3 and develop new tools to improve the new ecosystem. With the move to TypeScript and the introduction of Composition API, users and developers can expect performance improvements to both user-facing apps and the development environment.

Please note that Nuxt 3 is still in beta, so expect things to break. However, more features are coming to Nuxt 3. For all the features, you can check out the Nuxt 3 official doc.

Liked the article? Spread the word

Put your knowledge to practice

Try Bird on your next bug - you’ll love it

Try Bird later, from your desktop

Bird Call to action parrot
By clicking “Accept”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. View our Privacy Policy for more information.