2022-10-06 09:15:30 +00:00
|
|
|
---
|
|
|
|
title: "Kit Utilities"
|
|
|
|
description: Nuxt Kit provides composable utilities to help interacting with Nuxt Hooks and Nuxt Builder.
|
|
|
|
---
|
|
|
|
|
2022-04-06 05:56:08 +00:00
|
|
|
# Kit Utilities
|
2022-01-27 17:02:42 +00:00
|
|
|
|
2022-04-06 05:56:08 +00:00
|
|
|
::ReadMore{link="/guide/going-further/kit"}
|
2022-01-27 17:02:42 +00:00
|
|
|
::
|
|
|
|
|
|
|
|
## Utilities
|
|
|
|
|
|
|
|
### Modules
|
|
|
|
|
|
|
|
[source code](https://github.com/nuxt/framework/blob/main/packages/kit/src/module)
|
|
|
|
|
|
|
|
- `installModule(module, inlineOptions)`
|
|
|
|
|
2022-08-13 07:27:04 +00:00
|
|
|
### Programmatic Usage
|
2022-01-27 17:02:42 +00:00
|
|
|
|
|
|
|
[source code](https://github.com/nuxt/framework/blob/main/packages/kit/src/loader)
|
|
|
|
|
|
|
|
- `loadNuxt(loadOptions)`
|
|
|
|
- `buildNuxt(nuxt)`
|
|
|
|
- `loadNuxtConfig(loadOptions)`
|
|
|
|
|
|
|
|
### Compatibility
|
|
|
|
|
|
|
|
[source code](https://github.com/nuxt/framework/blob/main/packages/kit/src/compatibility.ts)
|
|
|
|
|
|
|
|
- `checkNuxtCompatibility(constraints)`
|
|
|
|
- `assertNuxtCompatibility(constraints)`
|
|
|
|
- `hasNuxtCompatibility(constraints)`
|
|
|
|
- `isNuxt2()`
|
|
|
|
- `isNuxt3()`
|
|
|
|
- `getNuxtVersion()`
|
|
|
|
|
2022-08-22 13:32:34 +00:00
|
|
|
### Auto-imports
|
|
|
|
|
2022-09-15 07:47:09 +00:00
|
|
|
[source code](https://github.com/nuxt/framework/blob/main/packages/kit/src/imports.ts)
|
2022-08-22 13:32:34 +00:00
|
|
|
|
2022-09-15 11:20:53 +00:00
|
|
|
- `addImports(imports)`
|
|
|
|
- `addImportsDir(autoImportDirs)`
|
2022-09-19 08:46:11 +00:00
|
|
|
- `addImportsSources(autoImportSources)`
|
2022-08-22 13:32:34 +00:00
|
|
|
|
2022-01-27 17:02:42 +00:00
|
|
|
### Components
|
|
|
|
|
|
|
|
[source code](https://github.com/nuxt/framework/blob/main/packages/kit/src/components.ts)
|
|
|
|
|
|
|
|
- `addComponentsDir(dir)`
|
|
|
|
- `addComponent(componentObject)`
|
|
|
|
|
|
|
|
### Context
|
|
|
|
|
|
|
|
[source code](https://github.com/nuxt/framework/blob/main/packages/kit/src/context.ts)
|
|
|
|
|
|
|
|
- `useNuxt()`
|
|
|
|
|
2022-11-10 08:41:34 +00:00
|
|
|
### Pages
|
|
|
|
|
|
|
|
[source code](https://github.com/nuxt/framework/blob/main/packages/kit/src/pages.ts)
|
|
|
|
|
|
|
|
- `extendPages (callback: pages => void)`
|
|
|
|
|
2022-01-27 17:02:42 +00:00
|
|
|
### Plugins
|
|
|
|
|
|
|
|
[source code](https://github.com/nuxt/framework/blob/main/packages/kit/src/plugin.ts)
|
|
|
|
|
|
|
|
- `addPlugin(pluginOptions, { append? })`
|
|
|
|
- `addPluginTemplate(pluginOptions, { append? })`
|
|
|
|
|
|
|
|
### Templates
|
|
|
|
|
|
|
|
[source code](https://github.com/nuxt/framework/blob/main/packages/kit/src/template.ts)
|
|
|
|
|
|
|
|
- `addTemplate(templateOptions)`
|
2022-10-24 08:53:02 +00:00
|
|
|
- `updateTemplates({ filter?: ResolvedNuxtTemplate => boolean })`
|
2022-01-27 17:02:42 +00:00
|
|
|
|
2022-09-15 16:10:50 +00:00
|
|
|
### Nitro
|
2022-01-27 17:02:42 +00:00
|
|
|
|
2022-09-15 16:10:50 +00:00
|
|
|
[source code](https://github.com/nuxt/framework/blob/main/packages/kit/src/nitro.ts)
|
2022-01-27 17:02:42 +00:00
|
|
|
|
2022-05-06 13:31:52 +00:00
|
|
|
- `addServerHandler (handler)`
|
|
|
|
- `addDevServerHandler (handler)`
|
2022-09-15 16:10:50 +00:00
|
|
|
- `useNitro()` (only usable after `ready` hook)
|
2022-11-03 21:03:12 +00:00
|
|
|
- `addServerPlugin`
|
|
|
|
- `addPrerenderRoutes`
|
2022-01-27 17:02:42 +00:00
|
|
|
|
|
|
|
### Resolving
|
|
|
|
|
|
|
|
[source code](https://github.com/nuxt/framework/blob/main/packages/kit/src/resolve.ts)
|
|
|
|
|
|
|
|
- `resolvePath (path, resolveOptions?)`
|
2022-02-07 21:00:20 +00:00
|
|
|
- `resolveAlias (path, aliases?)`
|
|
|
|
- `findPath (paths, resolveOptions?)`
|
2022-02-07 21:39:31 +00:00
|
|
|
- `createResolver (base)`
|
2022-01-27 17:02:42 +00:00
|
|
|
|
2022-08-22 13:32:34 +00:00
|
|
|
### Logging
|
|
|
|
|
|
|
|
[source code](https://github.com/nuxt/framework/blob/main/packages/kit/src/logger.ts)
|
|
|
|
|
|
|
|
- `useLogger(scope?)`
|
|
|
|
|
2022-01-27 17:02:42 +00:00
|
|
|
### Builder
|
|
|
|
|
|
|
|
[source code](https://github.com/nuxt/framework/blob/main/packages/kit/src/build.ts)
|
|
|
|
|
|
|
|
- `extendWebpackConfig(callback, options?)`
|
|
|
|
- `extendViteConfig(callback, options?)`
|
|
|
|
- `addWebpackPlugin(webpackPlugin, options?)`
|
|
|
|
- `addVitePlugin(vitePlugin, options?)`
|