Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 32 ยท First steps

What Nuxt is and why use it

Learn what Nuxt adds to Vue: file-based routing, server rendering, auto-imports and a built-in server. See when Nuxt fits and when plain Vue is enough.

Vue is a view library. It is excellent at turning state into a user interface, but it leaves the rest of the application to you: which router to use, how to render pages on the server, how to split code, where API endpoints live, how to deploy. Nuxt is a framework built on top of Vue that makes those decisions for you. You put files in the right folders, and Nuxt turns them into routes, server-rendered pages, API endpoints and an optimized build.

This course teaches Nuxt step by step. You should already know the basics of Vue (components, ref, computed, props); if not, start with Vue.js. A shorter tour of Nuxt exists in Nuxt Overview; here we go much deeper.

Real versus stand-in. Nuxt needs Node.js, a build tool and a dev server, none of which exist in this site's sandbox. So the vue, ts, bash and text blocks in this course are real Nuxt code and commands to read. The runnable <TryIt> examples are small stand-ins written in plain JavaScript that rebuild the idea behind a feature, so you can see how it works inside. They are teaching models, not Nuxt's actual source code.

What Nuxt is made of

Nuxt is not one piece of software but a well-chosen bundle:

  • Vue renders components.
  • Vue Router handles navigation, but Nuxt writes the route table for you from your files.
  • Vite is the dev server and bundler.
  • Nitro is the server engine. It answers HTTP requests, runs your API handlers, renders Vue to HTML and can be built for many hosting platforms.
  • Nuxt itself glues these together with conventions, auto-imports, data-fetching helpers and a module system.

One framework, five parts

Vue Components and reactivity.
Vue Router Pages and navigation.
Vite Fast dev server and build.
Nitro Server, API and rendering.

Nuxt adds the conventions that connect them.

1 / 2

What Nuxt adds over plain Vue

Everything Nuxt does can be built with plain Vue, Vue Router and a server of your own. The point is how much plumbing that takes. Here are the biggest gains:

  • File-based routing. A file pages/about.vue is the route /about. You never edit a route table (File-based routing).
  • Server-side rendering by default. The first response is real HTML, which helps search engines and makes the first paint fast. The browser then "hydrates" that HTML, so it becomes interactive (Rendering modes). The background is covered in SSR and Hydration.
  • Auto-imports. ref, computed, useFetch and the components in components/ are available without import lines (Auto-imports).
  • Data fetching that survives SSR. Data fetched on the server is sent along with the page, so the browser does not fetch it a second time (Data fetching).
  • A backend in the same project. Files in server/api/ become API endpoints, so you can keep secrets and database code on the server (Server routes).
  • Per-route rendering choices. One route can be pre-built, another cached, another client-only (Rendering modes).
  • Modules. One line in the config adds content from Markdown, image optimization, a UI kit, i18n and more (Plugins and modules).

The shape of a Nuxt project

Creating a project is one command, and running it is another. These are real commands, shown read-only:

Terminal
npm create nuxt@latest my-site
cd my-site
npm run dev

The dev server listens on http://localhost:3000 by default and reloads when you save. A minimal project needs very little code. This is a complete page, with no imports at all:

VUE
<!-- app/pages/index.vue (read-only) -->
<script setup lang="ts">
const count = ref(0)
</script>

<template>
  <main>
    <h1>Hello Nuxt</h1>
    <button @click="count++">Clicked {{ count }} times</button>
    <NuxtLink to="/about">About</NuxtLink>
  </main>
</template>

ref is auto-imported from Vue, and NuxtLink is a built-in component. Because the file is named index.vue inside pages/, it serves /. The next lesson shows the whole folder layout in Project structure.

Convention over configuration

The idea that ties it together is convention over configuration: if you follow the agreed folder and file names, Nuxt needs no setup. The stand-in below shows what that means for routing. The first half is what you would write by hand in a plain Vue Router project, one entry for each page. The second half derives the same table from a list of file names. Add a file to the list and the new route appears with no edit to any table.

JS Manual wiring versus convention

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Nuxt's real route generator does much more (nested routes, route names, validation, code splitting per page), but the principle is the same: your file tree is the source of truth.

Rendering at a glance

By default Nuxt does universal rendering: the server renders the page to HTML, and the browser hydrates it. But each route can use a different strategy, set in nuxt.config.ts:

TypeScript
// nuxt.config.ts (read-only)
export default defineNuxtConfig({
  routeRules: {
    '/': { prerender: true },         // built once at build time
    '/blog/**': { swr: 3600 },        // cached, refreshed in the background
    '/account/**': { ssr: false },    // client-only, like a plain SPA
  },
})

A page that never changes can be built once; a page behind a login that search engines cannot see does not need server rendering; a news page changes hourly and can be cached. The stand-in below captures that decision as a small function. It is a rule of thumb for the lesson, not an algorithm Nuxt uses.

JS Which rendering mode fits a page?

Press Run (or Ctrl + Enter) to see the console output here.

No output.

When not to use Nuxt

Nuxt is a strong default for public Vue sites and apps, but it is not always the right tool:

  • A small widget or an embedded component that lives inside a page of another stack is simpler with plain Vue and Vite.
  • A purely internal tool behind a login, with no SEO needs and no server code, runs fine as an SPA. Nuxt can do that too (ssr: false), but you may not need its extras.
  • A static content site with almost no interactivity might be even simpler in a dedicated static site generator.
  • Teams that need to avoid a server runtime can still use Nuxt in static mode, but should know which features that excludes (server routes, per-request rendering).

Nuxt also asks you to think about code that runs in two places. Anything that touches window or localStorage must wait until the browser, because the server has neither. You will meet these hydration rules in Hydration and SSR pitfalls. That small extra care is the price of the benefits.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does Nuxt do for routing?

    Nuxt scans pages/ and builds the Vue Router configuration from the file names, so adding a file adds a route.
  2. 2. Which part of the Nuxt stack answers HTTP requests and runs your API handlers?

    Nitro is the server engine. Vite builds the code, and Vue Router handles navigation.
  3. 3. Why does server-side rendering help a public blog?

    SSR sends rendered HTML first, then the browser hydrates it. JavaScript is still sent and still runs.
  4. 4. Which situation is the weakest fit for Nuxt?

    A tiny embedded widget does not need routing, SSR or a server, so plain Vue with Vite is lighter.

Summary

  • Nuxt is a framework on top of Vue that bundles Vue Router, Vite and the Nitro server with conventions.
  • Files in pages/ become routes, components and composables are auto-imported, and files in server/ become endpoints.
  • Pages are server-rendered and hydrated by default, and routeRules lets each route choose its own strategy.
  • Convention over configuration means following folder names instead of writing setup code.
  • Nuxt is a great fit for public, SEO-friendly sites and apps, and an unnecessary one for tiny embedded widgets.
  • Code that runs on both server and browser needs care, which later lessons cover.

Next, Project structure and conventions walks through every folder Nuxt expects and what each one does.