Modules
Nuxt Kit provides a set of utilities to help you create and use modules. Modules are the building blocks of Nuxt, offering a structured way to keep your code organized and modular.defineNuxtModule
Define a Nuxt module, automatically merging defaults with user provided options, installing any hooks that are provided, and calling an optional setup function for full control.
Type
Parameters
definition: A module definition object with the following properties:Usage
Using configKey to Make Your Module Configurable
When defining a Nuxt module, you can set a configKey to specify how users should configure the module in their nuxt.config.
Defining Module Compatibility Requirements
If you’re developing a Nuxt module and using APIs that are only supported in specific Nuxt versions, includecompatibility.nuxt.
Type Safety with .with()
When you need type safety for your resolved/merged module options, use the .with() method.
Lifecycle Hooks
You can define lifecycle hooks that run when your module is first installed or upgraded to a new version. Important: For lifecycle hooks to work, you must provide bothmeta.name and meta.version.
Specifying Module Dependencies
Use themoduleDependencies option to declare dependencies on other modules.