Skip to content

How to understand a Nuxt codebase

Nuxt is the full-stack Vue framework. It relies heavily on conventions and auto-imports: components, composables and utilities can be used without import statements, and files under `server/` become API routes run by Nitro. Nuxt 4 moved app code into an `app/` directory by default.

How to tell it's Nuxt

  • nuxt.config.ts and nuxt in package.json
  • pages/, components/, composables/ and server/ folders (inside app/ on Nuxt 4)
  • A generated .nuxt/ folder with auto-import type declarations

Where things usually live

nuxt.config.ts
Modules, runtime config, route rules, app head settings.
pages/
File-based routes; [id].vue is dynamic.
layouts/
Page layouts selected with definePageMeta.
components/ and composables/
Auto-imported by name; nested folders prefix component names.
middleware/
Route middleware that runs before navigation (for example, auth).
plugins/
Code that runs when the app starts, on server, client or both.
server/api/ and server/routes/
Nitro handlers defined with defineEventHandler.

Conventions, not rules. Real projects rename and move things, so confirm against the repository.

Where to start reading

  1. nuxt.config.ts, to see modules and runtime config
  2. The page under pages/ and its useFetch or useAsyncData calls
  3. server/api/ for the endpoints those calls hit

How a request moves through the code

  1. 1Server middleware and Nitro route rules run first.
  2. 2Route middleware in middleware/ runs, possibly redirecting.
  3. 3The page renders on the server; useFetch and useAsyncData fetch data and serialise it into the payload.
  4. 4Fetches to /api/* call server/api/ handlers directly during server rendering.
  5. 5The browser hydrates, reusing the payload instead of fetching again.

Questions to ask about the repository

  • Where is this auto-imported composable actually defined?
  • Which server routes exist under server/, and which pages call them?
  • What runs in plugins on startup, and on which side?
  • Which values in runtimeConfig are public, and which are server-only?

What trips people up

  • Auto-imports hide where things come from; search components/, composables/, utils/ and installed modules by name.
  • Only runtimeConfig.public reaches the browser; everything else in runtimeConfig is server-only.
  • The folder layout differs between Nuxt 3 and Nuxt 4, so check whether an app/ directory is in use.