Modules

Nuxt provides a module system to extend the framework core and simplify integrations. You don’t need to develop everything from scratch or maintain boilerplate if there is already a Nuxt module for it. Adding Nuxt modules is possible using nuxt.config.

Exploring Nuxt Modules

When developing production-grade applications with Nuxt you might find that the framework’s core functionality is not enough. Nuxt can be extended with configuration options and plugins, but maintaining these customizations across multiple projects can be tedious, repetitive and time-consuming. On the other hand, supporting every project’s needs out of the box would make Nuxt very complex and hard to use.

This is one of the reasons why Nuxt provides a module system that makes it possible to extend the core. Nuxt modules are async functions that sequentially run when starting nuxt in development mode using nuxi dev or building a project for production with nuxi build. They can override templates, configure webpack loaders, add CSS libraries, and perform many other useful tasks.

Best of all, Nuxt modules can be distributed in npm packages. This makes it possible for them to be reused across projects and shared with the community, helping create an ecosystem of high-quality add-ons.

👉

Read more in Nuxt 3 Compatible Modules.

The modules Property

Once you have installed the modules you can then add them to your nuxt.config.ts file under the modules property. Modules developers usually provide additional steps and details for usage.

nuxt.config.ts

  1. export default defineNuxtConfig({
  2. modules: [
  3. // Using package name (recommanded usage)
  4. '@nuxtjs/example',
  5. // Load a local module
  6. './modules/example',
  7. // Add module with inline-options
  8. ['./modules/example', { token: '123' }]
  9. // Inline module definition
  10. async (inlineOptions, nuxt) => { }
  11. ]
  12. })

⚠️

Nuxt modules are now build-time-only, and the buildModules property used in Nuxt 2 is deprecated in favor of modules.

Module development

Everyone has the opportunity to develop modules. Read more about developing modules in the Module Author Guide.

👉

Read more in Module Author Guide.