---
url: /plugins/plugin-barrel/reference/options.md
description: >-
  Configuration options for @kubb/plugin-barrel. Sets the re-export style for
  the index.ts barrel files Kubb generates.
---

# Options

`pluginBarrel` takes no arguments. You configure it through `output.barrel`, either on `defineConfig` to set the root barrel and the default every plugin inherits, or on a single plugin to override that plugin's barrel.

| Option | Type | Default | Description |
| ------ | ---- | ------- | ----------- |
| [`output.barrel`](#output-barrel) | `{ type: 'all' \| 'named' } \| false` | `false` | Re-export style for the barrel files |
| [`type`](#type) | `'all' \| 'named'` | Required | Named exports or a wildcard export |
| [`nested`](#nested) | `boolean` | `false` | Write an `index.ts` in every subdirectory |

### output.barrel

Toggle the export style and depth to see the generated barrels.

Controls how the generated `index.ts` (barrel) re-exports the output. Accepts `{ type: 'named' }` or `{ type: 'all' }`, optionally with `nested: true` (for example `{ type: 'named', nested: true }`) to write an `index.ts` in every subdirectory, or `false` to skip the barrel entirely. Kubb reads the plugin's own `output.barrel` first, falls back to `config.output.barrel` on `defineConfig`, and finally to `false`. Every generator plugin ships a default `output` that sets `barrel: { type: 'named' }`, but passing your own `output` replaces that object wholesale, so repeat `barrel` whenever you set `output` yourself.

The `type` field picks the export style. A plugin's `output.barrel` also accepts `nested`, so the plugin writes an `index.ts` in every subdirectory. The root `output.barrel` has no `nested` field and always stays flat.

Call a plugin with no `output` at all and it uses its own default, which already sets `barrel: { type: 'named' }`. The moment you pass an `output` object of your own, that default is replaced whole, so a plugin configured as `pluginTs({ output: { path: 'types' } })` has no `barrel` of its own and falls back to `config.output.barrel`, which is `false` unless you set it.

Set `barrel: { type: 'named' | 'all' }` on `defineConfig` to enable barrels everywhere: a root barrel, and the default every plugin without its own `output.barrel` inherits. A plugin that sets its own `output.barrel` overrides that inherited value, including back to `false`, which also drops its files from the root barrel.

|          |                                                        |
| -------: | :----------------------------------------------------- |
|    Type: | `{ type: 'all' \| 'named', nested?: boolean } \| false` |
| Default: | `false`                                                |

### type

Export style for the barrel files. Required whenever `output.barrel` is set to an object.

* `'named'` re-exports each symbol by name from the file's named exports. Best for tree-shaking and explicit imports.
* `'all'` uses `export *`, a smaller barrel that re-exports everything.

|          |                    |
| -------: | :----------------- |
|    Type: | `'all' \| 'named'` |
| Default: | Required, no default |

::: code-group

```typescript ['named']
// src/gen/index.ts
export { getUser, User } from './api/user'
export { getPost, Post } from './api/post'
export { User } from './api/types/User'
```

```typescript ['all']
// src/gen/index.ts
export * from './api/user'
export * from './api/post'
export * from './api/types/User'
```

:::

### nested

Changes what each barrel references. A barrel is written for every directory either way. With `nested: false`, the plugin's top barrel reaches through to the leaf files. With `nested: true`, each barrel re-exports only what sits directly inside its directory, including the subdirectory barrels below it, so callers can import from any depth. This field works on a plugin's `output.barrel` only.

|          |           |
| -------: | :-------- |
|    Type: | `boolean` |
| Default: | `false`   |

::: code-group

```typescript [nested: false (default) → barrels reference leaf files]
// src/gen/api/index.ts
export * from './user'
export * from './post'
export * from './types/User'

// src/gen/api/types/index.ts
export * from './User'
```

```typescript [nested: true → barrels reference sub-barrels]
// src/gen/api/index.ts re-exports its files and subdirectories
export * from './user'
export * from './post'
export * from './types'

// src/gen/api/types/index.ts re-exports its files
export * from './User'
```

:::
