Your First Layer
Four files, no build step, no publish. A layer that ships a component, a composable, a page and shared config — and a way to prove each one crossed the boundary.
What it is#
The fastest layer you can make lives in layers/ at your project root, because Nuxt scans that directory for you. No extends entry, no package, no install.
your-app/
├─ layers/
│ └─ branding/
│ ├─ nuxt.config.ts
│ ├─ app.config.ts
│ └─ app/
│ ├─ components/BrandBadge.vue
│ └─ composables/useBrand.ts
├─ app/
└─ nuxt.config.ts
Start the dev server and <BrandBadge /> is already auto-imported in your pages. Nothing else was configured.
Why you'd care#
Because this is the cheapest way to find out whether a boundary is the right one. Move a feature into layers/<name>/, run the app, and see what breaks. Every broken import is a dependency you didn't know that feature had.
If nothing breaks, the boundary was real, and promoting the folder to a package later is a git mv (that's the Intermediate series). If ten things break, you've learned something for the price of one folder.
Before#
app/components/BrandBadge.vue in the host app, imported by three pages, mentally tagged "branding stuff" and physically indistinguishable from everything else.
After#
// layers/branding/nuxt.config.ts
export default defineNuxtConfig({
$meta: { name: "branding" },
});
// layers/branding/app.config.ts
export default defineAppConfig({
brand: {
name: "VantolBennett",
accent: "#f5c542",
},
});
<!-- layers/branding/app/components/BrandBadge.vue -->
<script setup lang="ts">
const { brand } = useAppConfig();
</script>
<template>
<span
class="px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-widest"
:style="{ background: brand.accent, color: '#000' }"
>
{{ brand.name }}
</span>
</template>
// layers/branding/app/composables/useBrand.ts
export function useBrand() {
const { brand } = useAppConfig();
return { name: brand.name, accent: brand.accent };
}
Now, in the host app, with no import statement anywhere:
<!-- app/pages/index.vue -->
<template>
<BrandBadge />
</template>
Four things just crossed the boundary: a component (auto-imported), a composable (auto-imported), app config (deep-merged), and — if you add layers/branding/app/pages/brand.vue — a route.
app.config.ts is worth pausing on. It merges deeply across layers, and the host app wins on conflicts:
// app/app.config.ts — in the host app
export default defineAppConfig({
brand: { accent: "#8a5cff" }, // name stays 'VantolBennett', accent is overridden
});
That's the pattern for themeable layers: the layer ships defaults, the consumer overrides the keys it cares about, and neither has to know the full shape.
Do it yourself#
- Create
layers/branding/with the four files above. - Drop
<BrandBadge />into any page. It works with no import — confirm it, then confirm you didn't accidentally have a component of the same name already. - Add
app/app.config.tsin the host app overriding onlybrand.accent. Reload. The badge changes colour, the name doesn't. - Add
layers/branding/app/pages/brand.vueand visit/brand. A layer contributed a route. - Rename the folder to
layers/branding-two. Nuxt hard-restarts and everything still works — the directory name is not the boundary, the config file is.
Gotchas#
app/inside the layer, not next to it. Nuxt 4's defaultsrcDirisapp/, and it applies per layer.layers/branding/components/is ignored;layers/branding/app/components/is scanned. This is the single most common first-layer mistake.app.config.tssits at the layer root, besidenuxt.config.ts— not insideapp/.- Name collisions resolve silently. Two layers with
BrandBadge.vuedon't error; one wins. Step three covers which. layers/auto-scanning is root-relative. A layer's ownlayers/subdirectory is not recursively scanned into your app — nest deliberately, withextends, not by accident.- Config in a layer is a fallback, not a mandate. Anything the host app sets wins. If your layer must enforce something, that's a module, not a layer.
Recap#
A folder in layers/ with a nuxt.config.ts and an app/ directory is a working layer — components, composables, pages and app config all merge with zero wiring. The host app overrides the layer, never the other way round. Next: the exact rules of who wins.