# library

Add an internal or publishable TypeScript library


## When to use it

Create shared TypeScript code for your applications or a package you intend to distribute. Choose its platform and whether it is internal or publishable, then review the proposed directory and package name. Follow the [packages-only walkthrough](/docs/workflows/packages-only) for internal versus distributable libraries and release preparation.

## Usage

```sh
npm exec -- nx generate @megamono/plugin:library --name="<name>" --dry-run
```

Replace angle-bracket placeholders with reviewed values. Nx's `--dry-run` previews generator writes; remove it only after reviewing the plan. Examples use npm; use your workspace's package manager if it differs.

## Options

Use these options with `@megamono/plugin:library`. Nx uses the camelCase names shown here; the [CLI reference](/docs/cli) describes command-line aliases. Some options are required only for particular choices.

| Option | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `name` | Yes | string | — | — |
| `scope` | No | string | — | — |
| `platform` | No | string | "neutral" | — Allowed: "neutral", "web", "node", "mobile", "worker". |
| `type` | No | string | "util" | — Allowed: "util", "ui", "data", "feature". |
| `publishable` | No | boolean | false | Generate a buildable package in packages/ instead of an internal library in libs/. Does not enroll it in release automation. |
| `access` | No | string | — | Registry access for a publishable package; defaults to restricted. Allowed: "restricted", "public". |
| `skipInstall` | No | boolean | false | Write dependency declarations but do not run the deferred dependency installation. |
| `dryRun` | No | boolean | false | — |
| `planOnly` | No | boolean | false | — |
| `yes` | No | boolean | false | Apply the reviewed plan; otherwise only display it. |

## Next steps

Review changed files and run the affected project's checks. For options that accept structured values, run the generator's `--help` or consult the schema in the installed package.

- [All generators](/docs/generators)
- [CLI overview](/docs/cli)
- [Adopt an existing workspace](/docs/workflows/adoption)
