Nuxt/docs/content/1.docs/1.getting-started/9.layers.md
Christian Preston 77e2974f1c
docs: add nuxt layers introduction and authoring guide (#9405)
Co-authored-by: Alexander Lichter <github@lichter.io>
Co-authored-by: Sébastien Chopin <seb@nuxtjs.com>
Co-authored-by: Pooya Parsa <pooya@pi0.io>
Co-authored-by: Daniel Roe <daniel@roe.dev>
2022-12-05 11:44:28 +01:00

1.5 KiB

navigation.icon description
uil:layer-group Nuxt provides a powerful system that allows you to extend the default files, configs, and much more.

Layers

One of the core features of Nuxt 3 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. Some example use cases:

::list{type="success"}

  • Share reusable configuration presets across projects using nuxt.config and app.config
  • Create a component library using components/ directory
  • Create utility and composable library using composables/ and utils/ directories
  • Create Nuxt themes
  • Create Nuxt module presets
  • Share standard setup across projects ::

You can extend a layer by adding the extends property to the nuxt.config.ts 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
  ]
})

Authoring Nuxt Layers

See Layer Author Guide to learn more.

Examples