Skip to main content
The Nx project graph is a representation of all projects in your workspace and the dependencies between them. By default, Nx builds this graph by analyzing JavaScript and TypeScript source files. Project graph plugins let you extend the graph with additional projects, targets, and dependencies — including for languages and tools Nx doesn’t understand natively. Two exported members define the plugin API:
  • createNodesV2 — adds project nodes (and their targets) to the graph.
  • createDependencies — adds dependency edges between projects.
Set NX_DAEMON=false during plugin development. The Nx daemon caches plugin code, so changes won’t be reflected until the daemon restarts.

Registering a plugin

Add the plugin to the plugins array in nx.json:
For a local (unpublished) plugin, reference its entry point by path:

Adding nodes with createNodesV2

createNodesV2 is a tuple of [globPattern, asyncFunction]. Nx finds all files matching the glob and calls the function with the full list. Use createNodesFromFiles to process each file individually:

Adding inferred targets to existing projects

A common pattern is to check for the presence of a tool’s config file and add a target to the project if found:

How project configurations are merged

When multiple plugins identify the same project (same root directory), Nx merges their configurations:
Nx’s built-in plugins (which read project.json and package.json) run after plugins listed in nx.json. A project.json file will overwrite any conflicting configuration added by your plugin.

Passing options to a plugin

Options defined in nx.json are forwarded as the options parameter:

Adding dependencies with createDependencies

createDependencies lets a plugin add dependency edges to the project graph. Export it from the same index.ts as createNodesV2:
The CreateDependenciesContext provides:
  • projectsConfigurations — every project in the workspace.
  • externalNodes — external npm packages in the graph.
  • fileMap — all files in the workspace, indexed by project.
  • filesToProcess — only files changed since the last invocation (use this for incremental analysis).
  • nxJsonConfiguration — the contents of nx.json.

Dependency types

A static dependency is associated with a specific source file. Nx tracks which file defines the dependency and skips re-analysis when the file hasn’t changed.

Full createDependencies example

This plugin reads each project’s package.json and creates static dependencies for any dependencies entries that resolve to other Nx projects:

Visualizing the project graph

After modifying your plugin, inspect the resulting graph:
During development, disable the project graph cache so changes to your plugin are reflected immediately:

Testing project graph plugins

The fastest way to verify the computed graph is nx show project:
In an e2e test, assert on the computed configuration:
Set NX_CACHE_PROJECT_GRAPH=false in your e2e test environment to ensure the graph is recomputed from scratch during each test run.

Key project graph APIs