Nuxt Kit
@nuxt/kit provides features for module authors.
Nuxt Kit provides composable utilities to make interacting with Nuxt Hooks and Nuxt Builder Core and developing Nuxt Modules super easy!
Usage
Install dependency
You can install the latest nuxt kit by adding it to the dependencies
section of your package.json
. However, please consider always explicitly installing the @nuxt/kit
package even if it is already installed by nuxt.
{ "dependencies": { "@nuxt/kit": "npm:@nuxt/kit-edge@latest" }}
Import kit utilities
import { useNuxt } from '@nuxt/kit'
Nuxt kit, is an esm-only package meaning you cannot require('@nuxt/kit')
. As a workaround, we can use dynamic import to use it in the CommonJS context:
// This does NOT work!// const kit = require('@nuxt/kit')async function main() { const kit = await import('@nuxt/kit')}main()