Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/nrwl/nx/llms.txt

Use this file to discover all available pages before exploring further.

Nx is designed for incremental adoption. You don’t need to restructure your project or migrate to a new setup — just run one command and Nx starts working alongside your existing tools.

Add Nx with a single command

npx nx@latest init
Whether you have a monorepo, a single project, or something in between, nx init walks you through adding and configuring Nx. At the end you’ll have an Nx workspace ready to use.

What nx init does

When you run nx init in an existing npm, pnpm, or yarn workspace, Nx:
  1. Installs the nx package as a dev dependency in your root package.json.
  2. Creates nx.json — the Nx configuration file at the root of your workspace.
  3. Picks up your existing package.json scripts — every script defined in any package.json in the workspace is automatically available as an Nx task. No manual task configuration needed.
  4. Configures caching — Nx infers sensible cache inputs and outputs for common tools (Vite, Jest, TypeScript, etc.) so caching works immediately.
You do not need to rewrite or replace your existing package.json scripts. Nx wraps them — calling nx build my-app executes the build script from my-app/package.json, equivalent to running npm run build inside that directory.

After initializing

Once nx init completes, try these commands:
nx build <project-name>      # Run a task
nx build <project-name>      # Run again - instant cache hit
nx run-many -t build test    # Run tasks across all projects
nx graph                     # Visualize project dependencies

Incremental adoption path

Nx is modular — you can adopt as much or as little as you need. A typical adoption progression looks like this:
1

Start with task running and caching

After nx init, every package.json script is available as an Nx task with local caching. No further configuration is required.
nx build my-app
nx test my-lib
2

Add Nx plugins for your tech stack

Nx plugins for React, Angular, Node, Vite, Jest, and others add:
  • Precise cache input/output configuration (so cache invalidation is accurate)
  • Code generators for scaffolding new projects, components, and configurations
  • Inferred tasks from tool config files (e.g., a vite.config.ts automatically becomes a build target)
nx add @nx/react
nx add @nx/vite
3

Enable remote caching

Connect to Nx Cloud so cache hits are shared across your team and CI:
nx connect
Once connected, a build that passes on CI will never need to run again locally. Any developer or CI agent that runs the same task with the same inputs gets a cache hit.
4

Use affected commands in CI

In your CI pipeline, replace full builds with affected builds to only run tasks impacted by changed files:
nx affected -t build test lint
Nx compares your branch to the base branch, builds the project graph, and determines exactly which projects are affected.

In-depth adoption guides

Migrate to Nx

Step-by-step guide for migrating from Lerna, Turborepo, or a plain npm/pnpm/yarn workspace.

Angular plugin

Migrate an existing Angular CLI project to Nx with the automated migration command.

Set up CI

Connect Nx to GitHub Actions, GitLab, Azure, or any other CI provider.

Nx plugins

Add plugins for your tech stack to unlock auto-configured tasks, generators, and more.

Build docs developers (and LLMs) love