Nuxt

Also known as: Nuxt.js

On this page 7

Nuxt (also written Nuxt.js) is an open-source meta-framework built on Vue.js that adds routing, data fetching, server rendering and a deployable server layer to the Vue component model. In the field of web applications, it occupies the same position for Vue that Next.js occupies for React: it turns a user interface library into a complete application framework with conventions for project structure, rendering and deployment.

The core promise of Nuxt is rendering flexibility. A single Nuxt project can serve some pages through server-side rendering (SSR), prerender others as static HTML and run still others purely in the browser, which lets teams balance search visibility, performance and hosting cost route by route instead of committing the whole Web project to one model.

How Nuxt structures a Vue application

Nuxt works by convention over configuration: the location of a file in the project determines its role, and the framework generates the wiring that a plain Vue setup would require developers to write by hand. A component placed in the pages directory becomes a route, a file in server/api becomes an HTTP endpoint, and a function in composables becomes auto-imported wherever it is used.

Under the hood, current versions of Nuxt combine three main pieces. Vue 3 provides the component and reactivity model, Vite provides the development server and production bundling, and Nitro provides the server engine that renders pages, serves API routes and packages the output for different hosting targets. The following table maps the most important directories to their function.

Directory or fileRoleWhat Nuxt generates
pages/File-based routingRoute table with dynamic segments such as [id].vue
layouts/Shared page shellsWrappers for headers, footers and navigation
components/Reusable UI partsAutomatic imports without explicit import lines
composables/Shared reactive logicAuto-imported functions such as useCart()
middleware/Route guardsCode that runs before navigation completes
server/Backend endpointsNitro handlers for API and server routes
nuxt.config.tsCentral configurationModules, rendering rules and runtime settings
Core directories in a Nuxt project

Since Nuxt 4, application code lives by default in an app directory, which separates frontend source from server code and configuration. This change mainly affects project layout and editor performance, not the rendering model itself.

Rendering modes available in Nuxt

Nuxt supports several rendering strategies, and its default is universal rendering: the server produces complete HTML for the first request, and the browser then performs hydration, attaching Vue reactivity to that HTML so the page becomes interactive. After the first load, navigation proceeds through client-side routing without full page reloads.

Developers can override this default globally or per route through routeRules in the configuration, a mechanism Nuxt calls hybrid rendering. The table below compares the main options and their typical use.

ModeWhere HTML is producedTypical useMain trade-off
Universal (SSR)Server on each requestDynamic, personalized pagesNeeds a running server
Prerendering (SSG)At build timeDocumentation, blogs, landing pagesContent is fixed until rebuild
Client-only (SPA)In the browserDashboards behind loginWeak first paint and SEO
Stale-while-revalidateServer, then cachedCatalogs with frequent updatesVisitors may see slightly old data
Incremental regenerationServer, cached at the edgeLarge content sitesDepends on host support
Rendering strategies in Nuxt

Data fetching is coordinated with rendering through composables such as useFetch and useAsyncData. On the server they fetch data once and serialize it into the payload, so the browser reuses the result during hydration instead of requesting it again. Calling a plain fetch in a component instead often causes duplicate requests and hydration mismatches.

Nuxt belongs to the family of meta-frameworks, which wrap a component library with routing, rendering and build tooling. Its closest counterparts differ mainly in the underlying UI library and in how strongly they push server-centric patterns.

FrameworkUI libraryServer layerDistinctive approach
NuxtVue.jsNitroAuto-imports and per-route rendering rules
Next.jsReactBuilt-in Node and edge runtimeReact Server Components by default
SvelteKitSvelteAdapters per platformCompiled components with small runtime
RemixReactWeb Fetch API handlersLoaders and actions built on web standards
AstroFramework-agnosticAdapters per platformIslands architecture with minimal JavaScript
Nuxt and comparable meta-frameworks

Compared with a plain Vue.js single-page application, Nuxt adds server rendering, file-based routing and a backend layer, at the cost of a more opinionated structure and a server-aware programming model in which code may run in two environments.

Modules and deployment targets

Nuxt extends through modules, packages that hook into the build process to add features such as image optimization, content management from Markdown files, internationalization or authentication. A module can register components, composables, server routes and configuration in one step, which keeps integration code out of the application.

Deployment is handled by Nitro presets, which compile the same project into output suited to a specific platform. The choice of preset decides whether the application runs as a long-lived process, as serverless functions or as static files.

TargetBuild command or presetBest suited for
Node.js servernuxi build with node-server presetContainers and virtual machines
Static hostingnuxi generateFully prerendered sites on a CDN
Serverless functionsPlatform-specific presetVariable traffic with pay-per-use billing
Edge runtimeEdge worker presetLow latency close to visitors
Common deployment outputs for Nuxt

Limitations and common mistakes with Nuxt

The most frequent difficulty with Nuxt is the dual execution environment. Code in components and plugins may run both on the server and in the browser, so direct access to window, document or localStorage during setup fails on the server. Such code must be guarded with client-only components, the onMounted hook or a client plugin suffix.

  • Hydration mismatches appear when server and client render different markup, for example because of dates, random values or browser-only state.
  • Shared state leaks occur when a module-level variable is used for request data; on the server it is shared between users, so useState should be used instead.
  • Auto-import ambiguity can make large codebases harder to trace, because the origin of a function is not visible in the file.
  • Major-version migrations, such as the move from Nuxt 2 to Nuxt 3, required substantial rewrites because the framework moved to Vue 3 and a new server engine.

Nuxt is also not the right choice for every project. A small internal tool that never needs search visibility may be simpler as a client-rendered Vue application, while a content site with almost no interactivity may ship less JavaScript with an islands-based framework.

In simple terms

Vue.js is a toolkit for building the visible, interactive parts of a website. Nuxt is a ready-made frame around that toolkit. It decides where files go, how pages get their addresses and how the site is delivered to visitors.

Its most useful trick is that it can prepare pages in advance or on demand. Some pages are cooked fully on the server so they appear instantly and search engines can read them. Others are built once and served like printed leaflets. Others are assembled in the visitor’s browser. The developer picks the right method for each page, and Nuxt handles the plumbing.

A practical example

A mid-sized online furniture retailer rebuilds its storefront with Nuxt. The team prerenders about 300 editorial pages such as buying guides at build time, serves the product catalog of roughly 12,000 items with a stale-while-revalidate rule of ten minutes, and marks the checkout and account area as client-only, because those pages sit behind login and never need indexing.

Product data comes from a headless commerce backend through useFetch, so each product page arrives as complete HTML with price and stock already embedded. A small server/api endpoint proxies the inventory service and hides its credentials from the browser. The site is deployed with a serverless preset that scales during seasonal sales.

After launch, the team observes that product pages reach first contentful paint well under one second on typical mobile connections and that search engines index new products within days. The main lesson from the project is that choosing the rendering mode per route, rather than for the whole site, delivered most of the performance gain.