Nuxt Layers: Required and Optional Features
Nuxt 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
9009and base i18n messages:useAppToast(): toasts withshowSuccessToastandshowErrorToastuseConfirmationModal()anduseLoadingModal()useLogger()(client) anduseServerLogger('tag')(server), both return aconsolainstance- A Nitro plugin that logs every 5xx response, so handlers don't need a
try/catchjust to log - The extension points optional layers plug into (see below)
- emails: Email providers (Plunk, Resend),
useEmail()withsendTemplate()and the shared email components, see Emails - auth: better-auth with email/password, social login and passkeys, see Authentication:
- The global auth middleware and
useAuth()on the client requireAuth(),requireAdmin()andgetAuthSession()on the server- The Polar plugin of better-auth
useDb(), the auth tables and all database migrations, see Database
- The global auth middleware and
- payment: Polar products and pricing, see Payments
- dashboard: Dashboard layout, profile and security settings, billing, user admin and the
adminmiddleware, see 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
/testimonialspage, 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
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.
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 },
],
},
},
})
headerLinksandadminLinksare navigation entries with an i18nlabelKeyand anorder. The header and the admin navigation merge them with their built-in links byorder.slotsplace global components (*.global.vue) into places that required code renders with<ExtensionSlot name="...">:
| Slot | Where |
|---|---|
landing-sections | Sections on the home page between the FAQ and the final call to action |
layout-banners | Banners above the header of the default layout |
footer | Right column of the footer |
header-mobile | Bottom of the mobile header menu |
avatar-uploader | Avatar upload field in the profile settings |
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
- Delete
apps/web/layers/<feature> - Run
pnpm db:generate. It creates a migration that drops the feature's tables. - Remove npm dependencies only this feature used from
apps/web/package.json, e.g.@aws-sdk/client-s3andioredisforstorage
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
- Create
apps/web/layers/<name>/with anuxt.config.ts. Nuxt registers it automatically. - 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 underserver/api/dashboard/admin/<feature>) - database tables in
server/db/schema/*.tsand their types inshared/types/ - i18n messages in
i18n/locales/{en,de}.json, withi18n.localesset in the layer'snuxt.config.ts - email templates in
app/emails/and tests intest/
- pages (admin pages under
- Register links and slot components in
app/app.config.ts - Add new environment variables as Zod schemas to the layer's
runtimeConfigand toapps/web/.env.example
../../../../auth/server/db/schema/auth from server/db/schema/), because drizzle-kit doesn't resolve aliases.Tech Stack
The tech stack of Nuxt Starter Kit: one Nuxt 4 app built from layers in a small pnpm workspace without a build orchestrator, plus the key scripts.
PostgreSQL
Nuxt Starter Kit uses PostgreSQL with Drizzle ORM. Each layer owns its tables, drizzle-kit generates the migrations, and any PostgreSQL provider works.