Skip to main content
An Nx plugin is an npm package that extends Nx with generators, executors, and project graph logic. Plugins can be used locally within a single workspace or published to npm and shared across multiple repos.

Scaffolding a plugin

This creates a new Nx workspace with a plugin already configured.

Plugin structure

After generation, the plugin folder contains:
The index.ts file is the plugin entry point registered in nx.json. Export createNodesV2 and createDependencies from this file to extend the project graph.

Adding generators and executors

See local generators and local executors for detailed implementation guidance.

Inferring tasks with createNodesV2

The most powerful feature of a plugin is the ability to automatically create tasks for any project that has a particular config file. This removes the need for users to manually define targets in project.json. Export createNodesV2 from your plugin’s index.ts:

Registering your plugin in nx.json

Add the plugin to the plugins array in nx.json. You can pass options that are forwarded to your createNodesV2 function:
For a local plugin (not published to npm), reference the path directly:

Creating an init generator

If you create a generator named init, Nx runs it automatically when someone installs your plugin with nx add. Use it to register the plugin in nx.json:

Publishing a plugin to npm

1

Build the plugin

2

Update package.json

Make sure your package.json has the correct name, version, main, generators, and executors fields:
3

Publish to npm

4

Install in another workspace

If you have an init generator, it runs automatically.
The generated plugin comes with an e2e test suite that spins up a local Verdaccio registry, publishes your plugin, creates a fresh Nx workspace, and installs your plugin — exactly mirroring the real user experience.

Testing your plugin

The plugin generator creates an e2e project alongside your plugin. Run it with:
For unit testing the inferred task logic, use nx show project to inspect the computed project configuration:
In e2e tests you can assert on this output: