mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 23:52:06 +00:00
dc47c64f14
Co-authored-by: Daniel Roe <daniel@roe.dev> Co-authored-by: Sébastien Chopin <seb@nuxtjs.com> Co-authored-by: Pooya Parsa <pooya@pi0.io> Co-authored-by: pooya parsa <pyapar@gmail.com> Co-authored-by: Clément Ollivier <clement.o2p@gmail.com>
1.3 KiB
1.3 KiB
title | description |
---|---|
Nuxt Kit | @nuxt/kit provides features for module authors. |
Nuxt Kit
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'
::ReadMore{link="/api/advanced/kit" title="API > Advanced > Kit"} ::
::alert{type="warning"} Nuxt Kit utilities are only available for modules and not meant to be imported in runtime (components, Vue composables, pages, plugins, or server routes). ::
Nuxt Kit is an esm-only package meaning that you cannot require('@nuxt/kit')
. As a workaround, use dynamic import in the CommonJS context:
// This does NOT work!
// const kit = require('@nuxt/kit')
async function main() {
const kit = await import('@nuxt/kit')
}
main()