--- name: directory-structure description: Nuxt project folder structure, conventions, and file organization --- # Directory Structure Nuxt uses conventions-based directory structure. Understanding it is key to effective development. ## Standard Project Structure (Nuxt 4) In Nuxt 4, the **`app/` directory is the default source directory** (`srcDir` defaults to `app/`). ``` my-nuxt-app/ ├── app/ # Application source (default srcDir in Nuxt 4) │ ├── app.vue # Root component │ ├── app.config.ts # App configuration (runtime) │ ├── error.vue # Error page │ ├── router.options.ts # Vue Router options (Nuxt 4) │ ├── components/ # Auto-imported Vue components │ ├── composables/ # Auto-imported composables │ ├── layouts/ # Layout components │ ├── middleware/ # Route middleware │ ├── pages/ # File-based routing │ ├── plugins/ # Vue plugins │ └── utils/ # Auto-imported utilities ├── assets/ # Build-processed assets (CSS, images) — stays at root ├── public/ # Static assets (served as-is) — stays at root ├── server/ # Server-side code — stays at root │ ├── api/ # API routes (/api/*) │ ├── routes/ # Server routes │ ├── middleware/ # Server middleware │ ├── plugins/ # Nitro plugins │ └── utils/ # Server utilities (auto-imported) ├── shared/ # Shared code between app and server (Nuxt 4) │ ├── utils/ # Auto-imported in both app and server │ └── types/ # Shared TypeScript types ├── content/ # Content files (@nuxt/content) ├── layers/ # Local layers (auto-scanned) ├── modules/ # Local modules ├── nuxt.config.ts # Nuxt configuration ├── package.json └── tsconfig.json ``` ## Key Directories ### `app/` Directory In Nuxt 4, this is the default source directory (`srcDir: 'app/'`). All application code goes here. ```ts // nuxt.config.ts - override source directory export default defineNuxtConfig({ srcDir: 'src/', // Change from default 'app/' to 'src/' }) ``` ### `shared/` Directory (New in Nuxt 4) Code shared between the Vue app and the Nitro server: ``` shared/ ├── utils/ │ └── format.ts → auto-imported in both app/ and server/ └── types/ └── user.ts → shared TypeScript interfaces ``` ### `app/components/` Vue components auto-imported by name: ``` components/ ├── Button.vue →