One of the core features of Nuxt is the layers and extending support. You can extend a default Nuxt application to reuse components, utils, and configuration. The layers structure is almost identical to a standard Nuxt application which makes them easy to author and maintain.
nuxt.config and app.configcomponents/ directorycomposables/ and utils/ directoriesBy default, any layers within your project in the ~/layers directory will be automatically registered as layers in your project
Layer auto-registration was introduced in Nuxt v3.12.0
In addition, you can extend from a layer by adding the extends property to your nuxt.config file.
export default defineNuxtConfig({
extends: [
'../base', // Extend from a local layer
'@my-themes/awesome', // Extend from an installed npm package
'github:my-themes/awesome#v1', // Extend from a git repository
]
})
You can also pass an authentication token if you are extending from a private GitHub repository:
export default defineNuxtConfig({
extends: [
// per layer configuration
['github:my-themes/private-awesome', { auth: process.env.GITHUB_TOKEN }]
]
})
Nuxt uses unjs/c12 and unjs/giget for extending remote layers. Check the documentation for more information and all available options.
Read more about layers in the Layer Author Guide.
Watch a video from Learn Vue about Nuxt Layers.
Watch a video from Alexander Lichter about Nuxt Layers.
[
{
"title": "Server",
"path": "/nuxt/getting-started/server",
"stem": "nuxt/1.getting-started/8.server",
"description": "Build full-stack applications with Nuxt's server framework. You can fetch data from your database or another server, create APIs, or even generate static server-side content like a sitemap or a RSS feed - all from a single codebase.",
"icon": "i-ph-computer-tower"
},
{
"title": "Prerendering",
"path": "/nuxt/getting-started/prerendering",
"stem": "nuxt/1.getting-started/9.prerendering",
"description": "Nuxt allows pages to be statically rendered at build time to improve certain performance or SEO metrics",
"icon": "i-ph-code-block"
}
]