description: Nuxt Kit provides a set of utilities to help you work with components. You can register components globally or locally, and also add directories to be scanned for components.
Components are the building blocks of your Nuxt application. They are reusable Vue instances that can be used to create a user interface. In Nuxt, components from the components directory are automatically imported by default. However, if you need to import components from an alternative directory or wish to selectively import them as needed, `@nuxt/kit` provides the `addComponentsDir` and `addComponent` methods. These utils allow you to customize the component configuration to better suit your needs.
## `addComponentsDir`
Register a directory to be scanned for components and imported only when used. Keep in mind, that this does not register components globally, until you specify `global: true` option.
### Type
```ts
async function addComponentsDir (dir: ComponentsDir): void
A function that will be called for each component found in the directory. It accepts a component object and should return a component object or a promise that resolves to a component object.
-`global` (optional)
**Type**: `boolean`
**Default**: `false`
If enabled, registers components to be globally available.
-`island` (optional)
**Type**: `boolean`
If enabled, registers components as islands.
-`watch` (optional)
**Type**: `boolean`
Watch specified path for changes, including file additions and file deletions.
-`extensions` (optional)
**Type**: `string[]`
Extensions supported by Nuxt builder.
-`transpile` (optional)
**Type**: `'auto' | boolean`
Transpile specified path using build.transpile. If set to `'auto'`, it will set `transpile: true` if `node_modules/` is in path.
## `addComponent`
Register a component to be automatically imported.
### Type
```ts
async function addComponent (options: AddComponentOptions): void
interface AddComponentOptions {
name: string,
filePath: string,
pascalName?: string,
kebabName?: string,
export?: string,
shortPath?: string,
chunkName?: string,
prefetch?: boolean,
preload?: boolean,
global?: boolean,
island?: boolean,
mode?: 'client' | 'server' | 'all',
priority?: number,
}
```
### Parameters
#### `options`
**Type**: `AddComponentOptions`
**Required**: `true`
An object with the following properties:
-`name` (required)
**Type**: `string`
Component name.
-`filePath` (required)
**Type**: `string`
Path to the component.
-`pascalName` (optional)
**Type**: `pascalCase(options.name)`
Pascal case component name. If not provided, it will be generated from the component name.
-`kebabName` (optional)
**Type**: `kebabCase(options.name)`
Kebab case component name. If not provided, it will be generated from the component name.
-`export` (optional)
**Type**: `string`
**Default**: `'default'`
Specify named or default export. If not provided, it will be set to `'default'`.
-`shortPath` (optional)
**Type**: `string`
Short path to the component. If not provided, it will be generated from the component path.
If enabled, registers component as island. You can read more about islands in [`<NuxtIsland/>`](/docs/api/components/nuxt-island#nuxtisland) component description.