---
title: "Nuxt Layers: Required and Optional Features"
description: "I use Nuxt Layers to structure my application. Optional features live in their own layer, so you can remove one by deleting its folder."
canonical_url: "https://nuxtstarterkit.com/docs/architecture/layers"
---

> Index of every page on this site: [llms.txt](https://nuxtstarterkit.com/llms.txt)

[Nuxt Layers](https://nuxt.com/docs/getting-started/layers) let you split an application into parts that each bring their own pages, components, composables, server routes and configuration. Nuxt merges them into one app.

The kit keeps all layers in `apps/web/layers/`. Nuxt registers every folder there automatically: there is no `extends` array, and a layer has no `package.json`, `tsconfig.json` or ESLint config of its own.

## Required Layers

These layers are the foundation. The app doesn't work without them.

- **core**: Shared modules (Nuxt UI, Nuxt Content, i18n, SEO, Nuxt Image, Nuxt Fonts, Nuxt Security, Umami), the dev port `9009` and base i18n messages:
  - `useAppToast()`: toasts with `showSuccessToast` and `showErrorToast`
  - `useConfirmationModal()` and `useLoadingModal()`
  - `useLogger()` (client) and `useServerLogger('tag')` (server), both return a `consola` instance
  - A Nitro plugin that logs every 5xx response, so handlers don't need a `try/catch` just to log
  - The extension points optional layers plug into (see below)
- **emails**: Email providers (Plunk, Resend), `useEmail()` with `sendTemplate()` and the shared email components, see [Emails](https://nuxtstarterkit.com/docs/emails)
- **auth**: better-auth with email/password, social login and passkeys, see [Authentication](https://nuxtstarterkit.com/docs/authentication):
  - The global auth middleware and `useAuth()` on the client
  - `requireAuth()`, `requireAdmin()` and `getAuthSession()` on the server
  - The Polar plugin of better-auth
  - `useDb()`, the auth tables and **all** database migrations, see [Database](https://nuxtstarterkit.com/docs/database)
- **payment**: Polar products and pricing, see [Payments](https://nuxtstarterkit.com/docs/payments)
- **dashboard**: Dashboard layout, profile and security settings, billing, user admin and the `admin` middleware, see [Admin](https://nuxtstarterkit.com/docs/admin)

## Optional Layers

Each of these layers contains one feature, including its pages, admin pages, components, server APIs, database tables, i18n messages, email templates and tests.

- **blog**: Blog posts with Nuxt Content, prerendered at build time
- **docs**: Documentation pages with Nuxt Content
- **waitlist**: Signups with email confirmation and an admin list
- **testimonials**: Testimonials on the landing page and a `/testimonials` page, managed in the admin
- **banner**: App-wide banners, managed in the admin
- **storage**: File uploads to S3-compatible storage or the local disk, the avatar upload, and an upload rate limit with Redis, see [Images](https://nuxtstarterkit.com/docs/images#file-storage)

## Extension Points

Required layers never reference an optional layer. Instead, an optional layer registers its links and components in its own `app/app.config.ts`. When you delete the layer, the registration goes with it.

```ts [apps/web/layers/testimonials/app/app.config.ts]
export default defineAppConfig({
  extensions: {
    adminLinks: [
      { labelKey: 'pages.admin.links.testimonials', order: 30, to: '/dashboard/admin/testimonials' },
    ],
    headerLinks: [
      {
        icon: 'i-lucide-speech',
        labelKey: 'general.links.testimonials',
        order: 30,
        to: '/testimonials'
      },
    ],
    slots: {
      'landing-sections': [
        { component: 'TestimonialsLandingSection', order: 10 },
      ],
    },
  },
})
```

- `headerLinks` and `adminLinks` are navigation entries with an i18n `labelKey` and an `order`. The header and the admin navigation merge them with their built-in links by `order`.
- `slots` place global components (`*.global.vue`) into places that required code renders with `<ExtensionSlot name="...">`:

<table>
<thead>
  <tr>
    <th>
      Slot
    </th>
    
    <th>
      Where
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        landing-sections
      </code>
    </td>
    
    <td>
      Sections on the home page between the FAQ and the final call to action
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        layout-banners
      </code>
    </td>
    
    <td>
      Banners above the header of the default layout
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        footer
      </code>
    </td>
    
    <td>
      Right column of the footer
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        header-mobile
      </code>
    </td>
    
    <td>
      Bottom of the mobile header menu
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        avatar-uploader
      </code>
    </td>
    
    <td>
      Avatar upload field in the profile settings
    </td>
  </tr>
</tbody>
</table>

Use `useHasExtensionSlot(name)` to hide the surrounding UI when no layer fills a slot. The types are in `apps/web/layers/core/shared/types/extensions.ts`.

## Remove an Optional Feature

1. Delete `apps/web/layers/<feature>`
2. Run `pnpm db:generate`. It creates a migration that drops the feature's tables.
3. Remove npm dependencies only this feature used from `apps/web/package.json`, e.g. `@aws-sdk/client-s3` and `ioredis` for `storage`

CI builds the app once without each optional layer and runs typecheck, the unit tests and the build, so removing a feature keeps working as the kit evolves.

## Add a New Layer

1. Create `apps/web/layers/<name>/` with a `nuxt.config.ts`. Nuxt registers it automatically.
2. Put everything that belongs to the feature into the layer:

  - pages (admin pages under `app/pages/dashboard/admin/index/`), components and server APIs (admin APIs under `server/api/dashboard/admin/<feature>`)
  - database tables in `server/db/schema/*.ts` and their types in `shared/types/`
  - i18n messages in `i18n/locales/{en,de}.json`, with `i18n.locales` set in the layer's `nuxt.config.ts`
  - email templates in `app/emails/` and tests in `test/`
3. Register links and slot components in `app/app.config.ts`
4. Add new environment variables as Zod schemas to the layer's `runtimeConfig` and to `apps/web/.env.example`

<tip>

Schema files import tables of other layers with relative paths (`../../../../auth/server/db/schema/auth` from `server/db/schema/`), because drizzle-kit doesn't resolve aliases.

</tip>

## Sitemap

See the full [sitemap](https://nuxtstarterkit.com/sitemap.md) for all pages.
